Skip to content

Fail with MojoExecutionException on malformed supplemental model (#266) - #279

Open
elharo wants to merge 2 commits into
masterfrom
fix/issue-266-supplement-npe
Open

Fail with MojoExecutionException on malformed supplemental model (#266)#279
elharo wants to merge 2 commits into
masterfrom
fix/issue-266-supplement-npe

Conversation

@elharo

@elharo elharo commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Closes #266

Test-first

Added RemoteResourcesMojoTest.testMalformedSupplementalModelFailsWithMojoExecutionException(), which configures a supplemental-models.xml containing a well-formed <project> element that the strict MavenXpp3Reader rejects (an unrecognized element).

The test asserts that executing the mojo fails with a MojoExecutionException whose message contains "Unable to parse supplemental XML".

Before the fix this test fails with:

java.lang.NullPointerException: Cannot invoke "org.apache.maven.model.Model.getGroupId()" because "m" is null

Fix

getSupplement() now throws a MojoExecutionException (with the parse cause) instead of logging a warning and returning null, so a malformed supplemental model entry fails the build cleanly rather than crashing with an NPE in loadSupplements().

Verification

  • New test fails before the fix (NPE), passes after.
  • Full suite: mvn verify passes (11 unit tests, RAT).

@elharo elharo changed the title Skip malformed supplemental model entries instead of failing with NPE (#266) Fail with MojoExecutionException on malformed supplemental model (#266) Aug 2, 2026
@elharo elharo added the bug Something isn't working label Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NPE crash on malformed supplemental-model entry instead of clean error

1 participant