Skip to content

[MNG-8174] DefaultModelBuilder throws a NPE on self-referencing property #10598

Closed

Description

@jira-importer

Henrik Rueping opened MNG-8174 and commented

The method org.apache.maven.model.building.DefaultModelBuilder.build(...) throws a Null-Pointer Exception when trying to resolve a pom with a self-referencing property, e.g.

<properties>
  <prop>${prop}</prop>
</properties>

A (rather) minimal example can be found at

https://github.com/HenrikRueping/pom-property-resolution-test

The stacktrace is

java.lang.NullPointerException: Attribute value can not be null
	at org.codehaus.plexus.util.xml.Xpp3Dom.setAttribute(Xpp3Dom.java:208)
	at org.apache.maven.model.interpolation.StringVisitorModelInterpolator$ModelVisitor.visit(StringVisitorModelInterpolator.java:725)
	at org.apache.maven.model.interpolation.StringVisitorModelInterpolator$ModelVisitor.visit(StringVisitorModelInterpolator.java:730)
	at org.apache.maven.model.interpolation.StringVisitorModelInterpolator$ModelVisitor.visit(StringVisitorModelInterpolator.java:730)
	at org.apache.maven.model.interpolation.StringVisitorModelInterpolator$ModelVisitor.visit(StringVisitorModelInterpolator.java:730)
	at org.apache.maven.model.interpolation.StringVisitorModelInterpolator$ModelVisitor.visit(StringVisitorModelInterpolator.java:730)
	at org.apache.maven.model.interpolation.StringVisitorModelInterpolator$ModelVisitor.visit(StringVisitorModelInterpolator.java:693)
	at org.apache.maven.model.interpolation.StringVisitorModelInterpolator$ModelVisitor.visit(StringVisitorModelInterpolator.java:674)
	at org.apache.maven.model.interpolation.StringVisitorModelInterpolator$ModelVisitor.visit(StringVisitorModelInterpolator.java:524)
	at org.apache.maven.model.interpolation.StringVisitorModelInterpolator$ModelVisitor.visit(StringVisitorModelInterpolator.java:571)
	at org.apache.maven.model.interpolation.StringVisitorModelInterpolator$ModelVisitor.visit(StringVisitorModelInterpolator.java:232)
	at org.apache.maven.model.interpolation.StringVisitorModelInterpolator.interpolateModel(StringVisitorModelInterpolator.java:101)
	at org.apache.maven.model.building.DefaultModelBuilder.interpolateModel(DefaultModelBuilder.java:770)
	at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:385)
	at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:247)

It seems like the cause is that Xpp3Dom.setAttribute does not accept null values,
but the interpolate Method
in org.apache.maven.model.interpolation.StringVisitorModelInterpolator returns null on a self-referencing property.

My Expectation would be that in such a case either a ModelBuildingException is thrown, or it behaves like in the usual case of an undefined property, e.g. the string "${prop}" is in the parsed model.

Maybe it is a good idea to add for each test case with an undefined property an analogous test case with a self-referencing property.

In Eclipse this Exception is still thrown when editing a pom with a self-referencing property.

I would say this is a minor issue, currently I can simply catch the NullPointerException hoping that there are no other causes for a NullPointerException.


Affects: 3.8.8, 3.9.5, 3.9.8

Activity

  1. jira-importer commented on Jul 5, 2024

    @jira-importer
    Author

    Michael Osipov commented

    Does 3.8.8 fail as well?

  2. jira-importer commented on Jul 5, 2024

    @jira-importer
    Author
  3. jira-importer commented on Jul 5, 2024

    @jira-importer
    Author

    Henrik Rueping commented

    Yes 3.8.8 behaves the same way.

  4. added
    bug
    priority:minor
    on Jul 7, 2025
  5. added a commit that references this issue on Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority:minor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions