elharo commented on code in PR #185:
URL: 
https://github.com/apache/maven-toolchains-plugin/pull/185#discussion_r3637578398


##########
src/main/java/org/apache/maven/plugins/toolchain/jdk/SelectJdkToolchainMojo.java:
##########
@@ -262,8 +262,17 @@ private boolean matches(String key, String reqVal, String 
tcVal) {
     }
 
     private String getJdkHome(ToolchainPrivate toolchain) {
-        return ((Xpp3Dom) toolchain.getModel().getConfiguration())
-                .getChild("jdkHome")
-                .getValue();
+        ToolchainModel model = toolchain.getModel();
+        if (model == null) {
+            return null;

Review Comment:
    returns , and  returns . So if we can't determine the JDK home of the 
selected toolchain (null), it won't match the current JDK's home (unless that's 
also null), and the IfSame block is simply skipped — the toolchain is used 
as-is. No NPE is moved; the null is handled safely by .



##########
src/main/java/org/apache/maven/plugins/toolchain/jdk/SelectJdkToolchainMojo.java:
##########
@@ -262,8 +262,17 @@ private boolean matches(String key, String reqVal, String 
tcVal) {
     }
 
     private String getJdkHome(ToolchainPrivate toolchain) {
-        return ((Xpp3Dom) toolchain.getModel().getConfiguration())
-                .getChild("jdkHome")
-                .getValue();
+        ToolchainModel model = toolchain.getModel();
+        if (model == null) {
+            return null;

Review Comment:
   Objects.equals(null, null) returns true, and Objects.equals(null, "value") 
returns false. So if we cannot determine the JDK home of the selected toolchain 
(null), it will not match the current JDK home (unless that is also null), and 
the IfSame block is simply skipped the toolchain is used as-is. No NPE is moved 
upstream; the null is handled safely by Objects.equals.



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