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:23:55 UTC

[maven] branch maven-3.8.x 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 maven-3.8.x
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/maven-3.8.x by this push:
     new 4fbbcc322 [MNG-7637] Possible NPE in MavenProject#hashCode()
4fbbcc322 is described below

commit 4fbbcc322ece8f07cd7d6c40b499c2afcdabf60c
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
---
 .../src/main/java/org/apache/maven/project/MavenProject.java      | 8 ++------
 1 file changed, 2 insertions(+), 6 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 db0f4a901..7ec480cbd 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
@@ -1073,18 +1073,14 @@ public class MavenProject
         MavenProject that = (MavenProject) other;
 
         return Objects.equals( getArtifactId(), that.getArtifactId() )
-            && Objects.equals( getGroupId(), that.getGroupId() ) 
+            && Objects.equals( getGroupId(), that.getGroupId() )
             && Objects.equals( getVersion(), that.getVersion() );
     }
 
     @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()