Skip to content

[#10598] Fix NPE when a property references itself in a plugin configuration (backport #12932) - #12937

Open
elharo wants to merge 1 commit into
maven-3.9.xfrom
MNG-8174-interpolator-npe-self-referencing-property-3.9.x
Open

elharo wants to merge 1 commit into
maven-3.9.xfrom
MNG-8174-interpolator-npe-self-referencing-property-3.9.x

Conversation

@elharo

@elharo elharo commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #12932 (merge commit 8638f335) to maven-3.9.x, fixing #10598.

A self-referencing property used in a plugin configuration attribute caused an NPE during interpolation because interpolate() could return null while recursing, and the guard if (org != val) would still call setValue/setAttribute with null.

This backport:

  • Adds && val != null to both visit(Xpp3Dom) setters in StringVisitorModelInterpolator.
  • Adds regression test testRecursiveExpressionCycleInPluginConfiguration (asserts 2 model errors on 3.x, since the cycle is reported twice by the older plexus-interpolation) plus a new StringVisitorModelInterpolatorTest so the fix is actually exercised on 3.x.

Tested: focused new test + full StringSearchModelInterpolatorTest (33 tests) pass. Note: StringVisitorModelInterpolatorTest has 2 pre-existing, unrelated failures (testBasedir/testBaseUri) when projectDir is null, present even without this change.

Closes https://issues.apache.org/jira/browse/#10598

@elharo

elharo commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Failure doesn't immediately look related but worth investigating:

[ERROR] org.apache.maven.model.interpolation.StringVisitorModelInterpolatorTest.testBaseUri -- Time elapsed: 0.003 s <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: <myBaseUri/temp-repo> but was: <${project.baseUri}/temp-repo>
	at org.apache.maven.model.interpolation.AbstractModelInterpolatorTest.testBaseUri(AbstractModelInterpolatorTest.java:337)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

[ERROR] org.apache.maven.model.interpolation.StringVisitorModelInterpolatorTest.testBasedir -- Time elapsed: 0.001 s <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: <file://localhost/myBasedir/temp-repo> but was: <file://localhost/${basedir}/temp-repo>
	at org.apache.maven.model.interpolation.AbstractModelInterpolatorTest.testBasedir(AbstractModelInterpolatorTest.java:315)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

@gnodet gnodet added bug Something isn't working backport mvn3 labels Oct 14, 2026
@gnodet gnodet changed the title [MNG-8174] Fix NPE when a property references itself in a plugin configuration (backport #12932) [#10598] Fix NPE when a property references itself in a plugin configuration (backport #12932) Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport bug Something isn't working mvn3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants