elharo opened a new issue, #266:
URL: https://github.com/apache/maven-remote-resources-plugin/issues/266

   ## 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 <project> 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 `<project>` 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 `<project>` 
DOM→Model conversion hits this path.
   
   ## Suggested fix
   Handle the null model in `loadSupplements()` (e.g. `continue` with a 
warning, matching the `getSupplement` doc intent) or make `getSupplement` throw 
a `MojoExecutionException` on parse failure instead of returning null.


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