elharo opened a new pull request, #184:
URL: https://github.com/apache/maven-toolchains-plugin/pull/184

   Fixes #168
   
   ## Problem
   
   The `getJdkHome()` method in `SelectJdkToolchainMojo` had an unchecked null 
chain that could throw `NullPointerException`:
   
   ```java
   return ((Xpp3Dom) toolchain.getModel().getConfiguration())
           .getChild("jdkHome")
           .getValue();
   ```
   
   Each call could return null without a guard:
   1. `getModel()` could return null
   2. `getConfiguration()` could return null (causing NPE on cast)
   3. `(Xpp3Dom)` cast could throw `ClassCastException`
   4. `getChild("jdkHome")` could return null
   5. `getValue()` on null would throw NPE
   
   This could occur during `IfSame` mode execution.
   
   ## Fix
   
   Added null guards at each step in the chain, returning null if any step is 
null or the wrong type. Also replaced `System.lineSeparator()` with `\n` in the 
error message for consistency.


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