You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2022/12/18 11:22:58 UTC

[maven] branch master updated: [MNG-7637] Possible NPE in MavenProject#hashCode()

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/master by this push:
     new 7a1cc12a4 [MNG-7637] Possible NPE in MavenProject#hashCode()
7a1cc12a4 is described below

commit 7a1cc12a47a4082b7d6761bc960306bc8d9fd083
Author: Christoph Läubrich <ch...@laeubi-soft.de>
AuthorDate: Sun Dec 18 11:39:02 2022 +0100

    [MNG-7637] Possible NPE in MavenProject#hashCode()
    
    This closes #921
---
 maven-core/src/main/java/org/apache/maven/project/MavenProject.java | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
index d9307dae7..b8e42caef 100644
--- a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
+++ b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
@@ -909,11 +909,7 @@ public class MavenProject implements Cloneable {
 
     @Override
     public int hashCode() {
-        int hash = 17;
-        hash = 31 * hash + getGroupId().hashCode();
-        hash = 31 * hash + getArtifactId().hashCode();
-        hash = 31 * hash + getVersion().hashCode();
-        return hash;
+        return Objects.hash(getGroupId(), getArtifactId(), getVersion());
     }
 
     public List<Extension> getBuildExtensions() {