AshharAhmadKhan opened a new pull request, #6397:
URL: https://github.com/apache/fineract/pull/6397

   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.
   
   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
   
   Both .orElse(null) calls in 
GroupingTypesWritePlatformServiceJpaRepositoryImpl replaced with 
.orElseThrow(() -> new GroupLevelNotFoundException(id)), using the existing 
GroupLevelNotFoundException class.
   
   Added GroupingTypesWritePlatformServiceJpaRepositoryImplTest.java, covering:
   
   updateGroupThrowsGroupLevelNotFoundExceptionWhenGroupLevelMissing(): 
confirms updateGroup() throws GroupLevelNotFoundException when the referenced 
GroupLevel is missing.
   
   Verified locally end to end
   
   See https://issues.apache.org/jira/browse/FINERACT-2808


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to