-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
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