Skip to content

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

@jira-importer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:minorMinor loss of function, or other problem where easy workaround is present

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions