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

   ## JIRA Ticket
   https://issues.apache.org/jira/browse/FINERACT-2421
   
   ## Description
   This PR fixes a potential `NullPointerException` in 
`CalendarCommandFromApiJsonDeserializer` when extracting boolean values from 
JSON. This addresses the FIXME comments on lines 156 and 298 in the original 
file.
   
   ## Problem
   The `extractBooleanNamed` method can return `null` when the JSON value is 
null or missing. Using primitive `boolean` causes automatic unboxing which 
throws `NullPointerException`:
   ```java
   // FIXME - Throws NullPointerException when boolean value is null
   final boolean repeating = this.fromApiJsonHelper.extractBooleanNamed(...); 
// NPE!
   ```
   
   ## Solution
   Use `Boolean` wrapper type instead of primitive `boolean` and use null-safe 
comparison:
   ```java
   final Boolean repeating = this.fromApiJsonHelper.extractBooleanNamed(...);
   if (Boolean.TRUE.equals(repeating)) { ... }  // Null-safe
   ```
   
   
   


-- 
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