[
https://issues.apache.org/jira/browse/MNG-8174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Henrik Rueping updated MNG-8174:
--------------------------------
Affects Version/s: 3.8.8
> DefaultModelBuilder throws a NPE on self-referencing property
> -------------------------------------------------------------
>
> Key: MNG-8174
> URL: https://issues.apache.org/jira/browse/MNG-8174
> Project: Maven
> Issue Type: Bug
> Affects Versions: 3.8.8, 3.9.5, 3.9.8
> Reporter: Henrik Rueping
> Priority: Minor
>
> 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.
> {code:xml}
> <properties>
> <prop>${prop}</prop>
> </properties>
> {code}
> A (rather) minimal example can be found at
> [https://github.com/HenrikRueping/pom-property-resolution-test]
> The stacktrace is
> {code:java}
> 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)
> {code}
> 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.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)