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

Ashhar Ahmad Khan resolved FINERACT-2808.
-----------------------------------------
    Resolution: Fixed

> NullPointerException in GroupingTypesWritePlatformServiceJpaRepositoryImpl 
> when GroupLevel is missing
> -----------------------------------------------------------------------------------------------------
>
>                 Key: FINERACT-2808
>                 URL: https://issues.apache.org/jira/browse/FINERACT-2808
>             Project: Apache Fineract
>          Issue Type: Bug
>            Reporter: Ashhar Ahmad Khan
>            Assignee: Ashhar Ahmad Khan
>            Priority: Minor
>             Fix For: 1.16.0
>
>
> What is broken
> GroupingTypesWritePlatformServiceJpaRepositoryImpl fetches a GroupLevel via 
> groupLevelRepository.findById(id).orElse(null) in two places, 
> createGroupingType and updateGroupingType, and dereferences the result 
> immediately with no null check. If the group references a GroupLevel that 
> does not exist in the database, this throws an unhandled 
> NullPointerException, blocking group creation or update.
> Why it's broken
> The correct pattern already exists elsewhere in the same file, 
> findOneWithNotFoundDetection style lookups that throw a proper not found 
> exception instead of returning null. This convention was never applied to the 
> two GroupLevel lookups.
> Changes made
> Both .orElse(null) calls in 
> GroupingTypesWritePlatformServiceJpaRepositoryImpl replaced with 
> .orElseThrow(() -> new GroupLevelNotFoundException(id)), using the existing 
> GroupLevelNotFoundException class.
> Added GroupingTypesWritePlatformServiceJpaRepositoryImplTest.java, a 
> regression test confirming updateGroup throws GroupLevelNotFoundException 
> when the referenced GroupLevel is missing.



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

Reply via email to