You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "elharo (via GitHub)" <gi...@apache.org> on 2026/08/30 11:27:01 UTC

[PR] MNG-8174: Fix NPE when a property references itself in a plugin configuration [maven]

elharo opened a new pull request, #12932:
URL: https://github.com/apache/maven/pull/12932

   Fixes #10598 (MNG-8174)
   
   ### Problem
   When a POM property references itself (e.g. `<prop>${prop}</prop>`) and that
   property is also used inside a plugin configuration attribute such as
   `<filter token="key" value="${prop}"/>`, invoking the model interpolation
   throws
   
   ```
   java.lang.NullPointerException: Attribute value can not be null
       at org.codehaus.plexus.util.xml.Xpp3Dom.setAttribute(Xpp3Dom.java:179)
       at ...StringVisitorModelInterpolator$ModelVisitor.visit(StringVisitorModelInterpolator.java:727)
   ```
   
   A recursive expression cycle is detected by the interpolator, which then
   returns `null` for the unresolved expression. `visit(Xpp3Dom)` in
   `StringVisitorModelInterpolator` unconditionally called
   `dom.setAttribute(attr, val)` (and `dom.setValue(val)`) even when the
   interpolated value was `null`, causing the NPE. The `visit(Properties)`
   method already guarded against `null` in the identical situation.
   
   ### Fix
   When interpolation of an Xpp3Dom content value or attribute returns `null`
   (which happens on a recursive expression cycle), leave the original value
   untouched instead of writing `null` into the DOM. This mirrors the existing
   guard in `visit(Properties)`.
   
   ### Test
   Added `testRecursiveExpressionCycleInPluginConfiguration` to
   `AbstractModelInterpolatorTest`, which builds a model with a
   self-referencing property and a plugin configuration attribute referencing
   it. Before the fix the test fails with the NPE above; after the fix the
   interpolation completes, reports the recursive-expression-cycle error and
   the attribute keeps its original value.


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MNG-8174] Fix NPE when a property references itself in a plugin configuration [maven]

Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo merged PR #12932:
URL: https://github.com/apache/maven/pull/12932


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MNG-8174] Fix NPE when a property references itself in a plugin configuration [maven]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #12932:
URL: https://github.com/apache/maven/pull/12932#issuecomment-5468605127

   @elharo Please assign appropriate label to PR according to the type of change.


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org