You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Benjamin Bentmann (JIRA)" <ji...@codehaus.org> on 2009/07/02 21:00:22 UTC
[jira] Updated: (MNG-4227) DefaultArtifactVersion equals
implementation does not handle null
[ http://jira.codehaus.org/browse/MNG-4227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Benjamin Bentmann updated MNG-4227:
-----------------------------------
Affects Version/s: (was: 2.2.0)
(was: 2.1.0)
(was: 2.0.10)
(was: 2.0.9)
(was: 2.0.8)
3.0-alpha-2
I checked the code, the {{equals()}} impl looks good for all of the recent 2.x versions. This actually affects 3.x, as expected from the relation to embedded usage in an IDE.
> DefaultArtifactVersion equals implementation does not handle null
> -----------------------------------------------------------------
>
> Key: MNG-4227
> URL: http://jira.codehaus.org/browse/MNG-4227
> Project: Maven 2
> Issue Type: Bug
> Components: Artifacts and Repositories
> Affects Versions: 3.0-alpha-2
> Environment: Windows Vista w/ JDK 1.5.0_18
> Reporter: Sean Griffin
> Priority: Minor
>
> A NullPointerException is possible in org.apache.maven.artifact.versioning.DefaultArtifactVersion because it simply delegates to the compareTo() method as its implementation. The compareTo method need not handle objects of a different type or null objects (and in fact does not), but the equals() method is supposed to handle these two situations. In certain cases (although I have not been able to track down the exact cause of null argument) a NPE is thrown for this reason.
> It's fine to call compareTo() as the equals implementation, but it should first be wrapped in an instanceof check:
> Change "return compareTo( other ) == 0;"
> to
> if !(other instanceof DefaultArtifactVersion) return false;
> return compareTo(other) == 0;
> This bug is exposed when using the new NetBeans 6.7 "Show Dependency Graph" functionality on certain projects. Here is the full stack trace:
> java.lang.NullPointerException
> at org.apache.maven.artifact.versioning.DefaultArtifactVersion.compareTo(DefaultArtifactVersion.java:65)
> at org.apache.maven.artifact.versioning.DefaultArtifactVersion.equals(DefaultArtifactVersion.java:59)
> at org.apache.maven.artifact.versioning.Restriction.equals(Restriction.java:164)
> at java.util.AbstractList.equals(AbstractList.java:507)
> at org.apache.maven.artifact.versioning.VersionRange.equals(VersionRange.java:568)
> at org.apache.maven.shared.dependency.tree.DependencyNode.nullEquals(DependencyNode.java:890)
> at org.apache.maven.shared.dependency.tree.DependencyNode.equals(DependencyNode.java:825)
> at org.netbeans.modules.maven.graph.ArtifactGraphNode.represents(ArtifactGraphNode.java:116)
> at org.netbeans.modules.maven.graph.DependencyGraphScene.getGraphNodeRepresentant(DependencyGraphScene.java:173)
> at org.netbeans.modules.maven.graph.EdgeWidget.getConflictType(EdgeWidget.java:210)
> at org.netbeans.modules.maven.graph.EdgeWidget.(EdgeWidget.java:85)
> at org.netbeans.modules.maven.graph.DependencyGraphScene.attachEdgeWidget(DependencyGraphScene.java:202)
> at org.netbeans.modules.maven.graph.DependencyGraphScene.attachEdgeWidget(DependencyGraphScene.java:95)
> at org.netbeans.api.visual.graph.GraphScene.addEdge(GraphScene.java:152)
> at org.netbeans.modules.maven.graph.GraphConstructor.endVisit(GraphConstructor.java:133)
> at org.apache.maven.shared.dependency.tree.DependencyNode.accept(DependencyNode.java:317)
> at org.netbeans.modules.maven.graph.DependencyGraphTopComponent$8.run(DependencyGraphTopComponent.java:416)
> at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:577)
> at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1030)
--
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