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 2008/12/17 22:37:19 UTC
[jira] Commented: (MNG-3921) Modello generated model classes are
subject to NPEs in their hashCode() impl
[ http://jira.codehaus.org/browse/MNG-3921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=158362#action_158362 ]
Benjamin Bentmann commented on MNG-3921:
----------------------------------------
Looks like the {{hashCode()}} methods are actually hand-written in the MDOs, makes things easy to fix.
> Modello generated model classes are subject to NPEs in their hashCode() impl
> ----------------------------------------------------------------------------
>
> Key: MNG-3921
> URL: http://jira.codehaus.org/browse/MNG-3921
> Project: Maven 2
> Issue Type: Bug
> Components: Dependencies
> Affects Versions: 2.0.10
> Reporter: Benjamin Bentmann
>
> From [Henrique Prange|http://www.nabble.com/Re%3A--2.0.10-RC6--please-test-p21053429.html] on the user list:
> {noformat}
> java.lang.NullPointerException
> at org.apache.maven.model.Extension.hashCode(Extension.java:147)
> at java.lang.Object.toString(Object.java:219)
> at java.lang.String.valueOf(String.java:2827)
> at java.lang.StringBuffer.append(StringBuffer.java:219)
> at org.apache.maven.lifecycle.DefaultLifecycleExecutor.findExtensions(DefaultLifecycleExecutor.java:157)
> at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:140)
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
> at org.apache.maven.cli.MavenCli.main(MavenCli.java:301)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
> at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
> at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
> at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> {noformat}
> The actual bug is in the {{hashCode()}} impl generated by Modello:
> {code:java}
> public int hashCode()
> {
> int result = 17;
> result = 37 * result + getArtifactId() != null ? getArtifactId().hashCode() : 0;
> result = 37 * result + getGroupId() != null ? getGroupId().hashCode() : 0;
> result = 37 * result + getVersion() != null ? getVersion().hashCode() : 0;
> return result;
> }
> {code}
> due to operator precedence, this ends up being like
> {code:java}
> result = ( 37 * result + getVersion() ) != null ? getVersion().hashCode() : 0;
> {code}
> i.e. always triggering the call to {{getVersion()}} as the string concatenation delivers a non-null result.
> This bug is also present in at least Maven 2.0.9, but went unnoticed. It was now triggered by a debug statement added in [r724969|http://svn.eu.apache.org/viewvc/maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?r1=724969&r2=724968&pathrev=724969]
--
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