[ 
https://issues.apache.org/jira/browse/FINERACT-2710?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Adam Saghy resolved FINERACT-2710.
----------------------------------
    Resolution: Fixed

> Bulk-import recurring-deposit download template throws HTTP 500 
> (NullPointerException) when a recurring-deposit product has a null 
> minDepositTermType
> -----------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: FINERACT-2710
>                 URL: https://issues.apache.org/jira/browse/FINERACT-2710
>             Project: Apache Fineract
>          Issue Type: Bug
>          Components: DataImportTool
>            Reporter: Farooq Ayoade
>            Assignee: Farooq Ayoade
>            Priority: Minor
>             Fix For: 1.16.0
>
>
>  ---Observed behavior
>   GET /v1/recurringdepositaccounts/downloadtemplate returns HTTP 500 on a 
> tenant that has at least one recurring-deposit
>   product with a null minimum-deposit-term type:
>   {noformat}
>   java.lang.NullPointerException: Cannot invoke
>     "org.apache.fineract.infrastructure.core.data.EnumOptionData.getValue()"
>     because the return value of
>     
> "org.apache.fineract.portfolio.savings.data.RecurringDepositProductData.getMinDepositTermType()"
>  is null
>       at 
> org.apache.fineract.infrastructure.bulkimport.populator.RecurringDepositProductSheetPopulator.populate(RecurringDepositProductSheetPopulator.java:84)
>       at 
> org.apache.fineract.infrastructure.bulkimport.populator.recurringdeposit.RecurringDepositWorkbookPopulator.populate(...)
>   {noformat}
>   Expected behavior
>   
>   The template downloads successfully (HTTP 200). A recurring-deposit product 
> with no minimum-deposit-term type simply
>   leaves that lookup cell blank — exactly as the populator already does for 
> the other optional product fields.
>   Steps to reproduce
>   
>   1. Create a recurring-deposit product without a minimum-deposit-term / 
> term-type.
>   2. GET 
> /fineract-provider/api/v1/recurringdepositaccounts/downloadtemplate?dateFormat=dd%20MMMM%20yyyy.
>   3. Observe HTTP 500 with the NPE above.
>   Root cause
>   
>   RecurringDepositProductSheetPopulator.populate() writes the 
> min-deposit-term-type cell without a null guard, while
>   every sibling optional field around it is guarded:
>   {code:java}
>   writeBoolean(PRECLOSURE_PENAL_APPLICABLE_COL, row, 
> product.isPreClosurePenalApplicable());
>   writeString(MIN_DEPOSIT_TERM_TYPE_COL, row, 
> product.getMinDepositTermType().getValue());   // <-- no null check
>   if (product.getMinDepositAmount() != null) { ... }   // siblings ARE guarded
>   if (product.getMaxDepositAmount() != null) { ... }
>   if (product.getMinDepositTerm()   != null) { ... }
>   {code}
>   
>   getMinDepositTermType() can be null for a product that never set one, so 
> .getValue() NPEs and 500s the whole template.
>   Note that the fixed-deposit product sheet populator already guards the 
> equivalent field, so this is an inconsistency between two sibling populators 
> rather than a design decision.
>   Proposed fix
>   Guard the write like its siblings:
>   {code:java}
>   if (product.getMinDepositTermType() != null) {
>       writeString(MIN_DEPOSIT_TERM_TYPE_COL, row, 
> product.getMinDepositTermType().getValue());
>   }
>   {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to