Summary
The getJdkHome() method in SelectJdkToolchainMojo has an unchecked null chain that can throw a NullPointerException. The equivalent method in ToolchainMojo correctly guards against nulls.
Location
SelectJdkToolchainMojo.java:264-268
private String getJdkHome(ToolchainPrivate toolchain) {
return ((Xpp3Dom) toolchain.getModel().getConfiguration())
.getChild("jdkHome")
.getValue();
}
Problem
Each call in the chain can return null without a guard:
toolchain.getModel() could return null
getModel().getConfiguration() could return null (causing NPE on the cast)
(Xpp3Dom) cast itself could throw ClassCastException if configuration is not Xpp3Dom
.getChild("jdkHome") could return null
.getValue() on null would throw NPE
Compare with the properly guarded version in ToolchainMojo.
Impact
Can cause NPE during IfSame mode execution, specifically on this line:
&& Objects.equals(getJdkHome(currentJdkToolchain), getJdkHome(toolchain)))
Suggested Fix
Add null guards matching the pattern used in ToolchainMojo, or better yet, reuse that method by extracting it to a shared utility.
Summary
The
getJdkHome()method inSelectJdkToolchainMojohas an unchecked null chain that can throw aNullPointerException. The equivalent method inToolchainMojocorrectly guards against nulls.Location
SelectJdkToolchainMojo.java:264-268Problem
Each call in the chain can return null without a guard:
toolchain.getModel()could return nullgetModel().getConfiguration()could return null (causing NPE on the cast)(Xpp3Dom)cast itself could throwClassCastExceptionif configuration is notXpp3Dom.getChild("jdkHome")could return null.getValue()on null would throw NPECompare with the properly guarded version in
ToolchainMojo.Impact
Can cause NPE during
IfSamemode execution, specifically on this line:Suggested Fix
Add null guards matching the pattern used in
ToolchainMojo, or better yet, reuse that method by extracting it to a shared utility.