Kigenyi Wilfred created FINERACT-2432:
-----------------------------------------
Summary: LoanProductDataValidator.validateLoanScheduleType()
throws NullPointerException when loanScheduleType is null
Key: FINERACT-2432
URL: https://issues.apache.org/jira/browse/FINERACT-2432
Project: Apache Fineract
Issue Type: Improvement
Components: Loan
Affects Versions: 1.14.0
Reporter: Kigenyi Wilfred
Fix For: 1.15.0
The {{validateLoanScheduleType()}} method in {{LoanProductDataValidator}} does
not handle null values properly, causing a {{NullPointerException}} when the
{{loanScheduleType}} parameter is present in the JSON payload but has a null
value.
*Steps to reproduce*
# Attempt to create a loan product with the following json payload:{
"loanScheduleType": null,
"transactionProcessingStrategyCode": "advanced-payment-allocation-strategy",
... [other required fields]
}
# The validation fails with a {{NullPointerException}} instead of gracefully
handling the null value.
*Current Behavior:*
* The method {{validateLoanScheduleType()}} extracts the {{loanScheduleType}}
value
* It validates using {{.isOneOfEnumValues(LoanScheduleType.class)}}
* It then immediately calls {{LoanScheduleType.valueOf(loanScheduleType)}} on
lines 2803 and 2810 without checking if the value is null
* This causes a {{NullPointerException}} when {{loanScheduleType}} is null
*Expected Behavior:* Since {{loanScheduleType}} is an optional field (the
method is only called when {{parameterExists()}} returns true), the validator
should:
# Validate the enum value if provided
# Gracefully skip further validation logic if the value is null
# Not throw a {{NullPointerException}}
*Root Cause:* In file:
{{fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/serialization/LoanProductDataValidator.java}}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)