Potential NPE in SelectJdkToolchainMojo.getJdkHome() from unchecked null chain
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- java
- Domain
- build-system, tooling
Research direction
Start at SelectJdkToolchainMojo.java:264-268 and compare getJdkHome() with the guarded equivalent in ToolchainMojo. Verify the IfSame-mode call no longer throws for missing model, configuration, or jdkHome data, while preserving the existing JDK-home lookup behavior.
Written by the indexing model from the issue text.
Description
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 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 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.
- Dominant language
- Java
- Stars
- 27
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/maven-toolchains-plugin
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
All issues in apache/maven-toolchains-plugin
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100