ops4j / org.ops4j.pax.construct

Build, manage and deploy many types of OSGi bundles
https://ops4j1.jira.com/wiki/display/paxconstruct/Pax+Construct
24 stars 14 forks source link

maven-pax-plugin throws NPE [PAXCONSTRUCT-131] #143

Open ops4j-issues opened 14 years ago

ops4j-issues commented 14 years ago

Madhanraj Meignanam created PAXCONSTRUCT-131

We are using maven-pax-plugin to read some of the POM properties during maven build that uses our custom maven plugin. the maven-pax-plugin throws an NPE in certain instances:

java.lang.NullPointerException
exec at java.util.Hashtable.put(Hashtable.java:775)
exec at java.util.Properties.setProperty(Properties.java:563)
exec at org.ops4j.pax.construct.util.XppPom.getProperties(XppPom.java:671)

The following method in rg.ops4j.pax.construct.util.XppPom

public Properties getProperties()
{
Properties properties = new Properties();

Xpp3Dom map = m_pom.getChild( "properties" );
if( null != map )
{
Xpp3Dom[] entries = map.getChildren();
for( int i = 0; i < entries.length; i++ )

{ properties.setProperty( entries[i].getName(), entries[i].getValue() ); }

}

return properties;
}

needs to be changed to have the NULL check:

....
if (null != map) {
Xpp3Dom[] entries = map.getChildren();
for (int i = 0; i < entries.length; i++)

{ if (entries[i].getName() != null && entries[i].getValue() != null) properties.setProperty(entries[i].getName(), entries[i] .getValue()); }

}
...

We have extended this class and overridden the getProperties method to workaround this issue. Also, we had to use reflection to access some of the members that are not visible.

Please let me know if any more information is needed.

Thanks,
Madhan


Affects: 1.4 Fixed in: 1.7.0 Votes: 0, Watches: 1

ops4j-issues commented 13 years ago

Andreas Pieber commented

I've no idea if this is still a valid problem, but since 1.4 is already released I've moved it to 1.5