maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jared Roberts (JIRA)" <j...@codehaus.org>
Subject [jira] Commented: (MNG-5103) NPE thrown when DefaultArtifact.getSelectedVersion is called
Date Tue, 24 May 2011 23:14:22 GMT

    [ http://jira.codehaus.org/browse/MNG-5103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=268362#action_268362
] 

Jared Roberts commented on MNG-5103:
------------------------------------

I'm resurrecting this from MNG-4887 because I also ran into the same issue. For certain artifacts,
it seems that the versionRange does not get initialized and will throw an NPE when [{{DefaultArtifact.getSelectedVersion()}}|http://maven.apache.org/ref/2.2.1/maven-artifact/xref/org/apache/maven/artifact/DefaultArtifact.html#618]
is called. I encountered it while using Maven 2.1.0 and 2.2.1. Switching to 3.0.1 resolved
my specific issue, so I assume something changed in the way the Artifact gets created. The
original poster referenced using {{DefaultArtifact.getVersionRange()}} where there is a relevant
[comment|http://maven.apache.org/ref/2.2.1/maven-artifact/xref/org/apache/maven/artifact/DefaultArtifact.html#513]
hinting that further investigation was probably needed.

I worked around the issue by using the following code block
{code:title=Before.java}
Artifact dep = ...;
ArtifactVersion selectedVersion = dep.getSelectedVersion();
{code}
{code:title=After.java}
Artifact dep = ...;
ArtifactVersion selectedVersion = dep.getVersionRange().getSelectedVersion(dep);
{code}

> NPE thrown when DefaultArtifact.getSelectedVersion is called
> ------------------------------------------------------------
>
>                 Key: MNG-5103
>                 URL: http://jira.codehaus.org/browse/MNG-5103
>             Project: Maven 2 & 3
>          Issue Type: Bug
>          Components: Artifacts and Repositories
>    Affects Versions: 3.0
>         Environment: not env dependent
>            Reporter: Jared Roberts
>
> getSelectedVersion() uses the versionRange variable directly instead of using getVersionRange()
which creates the version range from version if its null.
> This bug when using the appfuse warpath plugin when doing a double war overlay

-- 
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

        

Mime
View raw message