Björn Nilsson created FINERACT-2560:
---------------------------------------
Summary: NullPointerException in
calcInterestTransactionWaivedAmount
Key: FINERACT-2560
URL: https://issues.apache.org/jira/browse/FINERACT-2560
Project: Apache Fineract
Issue Type: Bug
Components: Loan
Reporter: Björn Nilsson
When Fineract processes a bulk repayment that fully pays off a loan, it
triggers accrual processing on loan closure. The method
calcInterestTransactionWaivedAmount streams through the loan's
transaction-to-repayment-schedule mappings and checks if each transaction is
reversed, is an interest waiver, etc.
The problem: during the closure event, some mappings have a null
getLoanTransaction() because the repayment transaction hasn't been fully
persisted to the database yet. The code calls t.isReversed() on that null
reference, which throws a NullPointerException.
The fix adds a tm.getLoanTransaction() != null check before accessing the
transaction:
// Before (crashes)
.filter(tm -> transactionPredicate.test(tm.getLoanTransaction()))
// After (safe)
.filter(tm -> tm.getLoanTransaction() != null &&
transactionPredicate.test(tm.getLoanTransaction()))
Without it, bulk repayments that close a loan fail with an NPE, leaving the
loan in an inconsistent state.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)