apache / apache/maven-remote-resources-plugin
NPE crash on malformed supplemental-model entry instead of clean error
- Dominant language
- Java
- Stars
- 17
- Forks
- 18
- Avg merge
- 6h 5m
- Merged PRs (30d)
- 5
Description
## Summary
`getSupplement(Xpp3Dom)` swallows XML parse errors and returns a **null** `Model`, and the caller then dereferences it unconditionally → `NullPointerException` instead of a clean error message.
`src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java:1008-1033`
```java
protected Model getSupplement(Xpp3Dom supplementModelXml) throws MojoExecutionException {
...
try {
model = modelReader.read(new StringReader(supplementModelXml.toString()));
...
} catch (IOException e) {
getLog().warn("Unable to read supplemental XML: " + e.getMessage(), e);
} catch (XmlPullParserException e) {
getLog().warn("Unable to parse supplemental XML: " + e.getMessage(), e);
}
return model; // null when the inner element is malformed
}
```
`loadSupplements()` then calls:
```java
Model m = getSupplement(dom);
supplementMap.put(generateSupplementMapKey(m.getGroupId(), m.getArtifactId()), m); // NPE if m == null
```
`src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java:1082-1083`
## Impact
A malformed `` entry inside `supplemental-models.xml` (e.g. an invalid model element that `MavenXpp3Reader` rejects) crashes the build with an unhelpful `NullPointerException` rather than the intended warning/error path. Note the outer wrapper XML is parsed by `SupplementalDataModelXpp3Reader` in `loadSupplements()` and fails there cleanly; only the inner `` DOM→Model conversion hits this path.
## Suggested fix
throw a `MojoExecutionException` on parse failure instead of returning null.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java at getSupplement(Xpp3Dom) lines 1008-1033, then trace its call from loadSupplements() around lines 1082-1083. Check the existing warning and exception flow for malformed inner project XML. Done means parse failures produce a clean MojoExecutionException rather than returning null and causing an NPE.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100