ParseVersionMojo throws NPE when there is no qualifier
------------------------------------------------------

                 Key: MBUILDHELPER-11
                 URL: http://jira.codehaus.org/browse/MBUILDHELPER-11
             Project: Maven 2.x Build Helper Plugin
          Issue Type: Bug
    Affects Versions: 1.3
            Reporter: Horst Studer


When the version has no qualifier (like version "1.0.0"), the ParseVersionMojo 
throws a NullPointerException.

java.lang.NullPointerException
        at java.util.Hashtable.put(Hashtable.java:394)
        at java.util.Properties.setProperty(Properties.java:143)
        at 
org.codehaus.mojo.buildhelper.ParseVersionMojo.execute(ParseVersionMojo.java:108)
        at 
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)

The mojo creates an org.apache.maven.artifact.versioning.DefaultArtifactVersion 
from the version string.

The DefaultArtifactVersion returns dafault values of 0 (zero) for all integer 
version parts, but
getQualifier() returns null if there is no qualifier.

Thus

        props.setProperty( propertyPrefix + ".qualifier", 
artifactVersion.getQualifier() );

causes a NullPointerException.

It would probably be the best solution to set an empty string value if there is 
no qualifier:

        String qualifier = artifactVersion.getQualifier();
        props.setProperty(propertyPrefix + ".qualifier", qualifier != null ? 
qualifier : "");


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to