You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2017/12/21 22:10:44 UTC

[2/3] maven git commit: [MNG-6300] Multi module release creates empty directories in war file instead of jars Switch to Objects.hasCode and Objects.equals Add @Override

[MNG-6300] Multi module release creates empty directories in war file instead of jars
Switch to Objects.hasCode and Objects.equals
Add @Override


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/dce9c9f7
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/dce9c9f7
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/dce9c9f7

Branch: refs/heads/MNG-6300_ProjectArtifactsCache-bug
Commit: dce9c9f7ace703e5bd870d665cab78e7ffb43f45
Parents: 13a408a
Author: rfscholte <rf...@apache.org>
Authored: Sat Dec 16 20:52:36 2017 +0100
Committer: rfscholte <rf...@apache.org>
Committed: Sat Dec 16 20:52:36 2017 +0100

----------------------------------------------------------------------
 .../artifact/DefaultProjectArtifactsCache.java  | 50 ++++++++++----------
 1 file changed, 25 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/dce9c9f7/maven-core/src/main/java/org/apache/maven/project/artifact/DefaultProjectArtifactsCache.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/DefaultProjectArtifactsCache.java b/maven-core/src/main/java/org/apache/maven/project/artifact/DefaultProjectArtifactsCache.java
index 1c427f2..87d2e44 100644
--- a/maven-core/src/main/java/org/apache/maven/project/artifact/DefaultProjectArtifactsCache.java
+++ b/maven-core/src/main/java/org/apache/maven/project/artifact/DefaultProjectArtifactsCache.java
@@ -25,6 +25,7 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -117,16 +118,16 @@ public class DefaultProjectArtifactsCache
             this.aggregating = aggregating;
 
             int hash = 17;
-            hash = hash * 31 + hash( groupId );
-            hash = hash * 31 + hash( artifactId );
-            hash = hash * 31 + hash( version );
-            hash = hash * 31 + hash( dependencyArtifacts );
-            hash = hash * 31 + hash( workspace );
-            hash = hash * 31 + hash( localRepo );
+            hash = hash * 31 + Objects.hashCode( groupId );
+            hash = hash * 31 + Objects.hashCode( artifactId );
+            hash = hash * 31 + Objects.hashCode( version );
+            hash = hash * 31 + Objects.hashCode( dependencyArtifacts );
+            hash = hash * 31 + Objects.hashCode( workspace );
+            hash = hash * 31 + Objects.hashCode( localRepo );
             hash = hash * 31 + RepositoryUtils.repositoriesHashCode( repositories );
-            hash = hash * 31 + hash( collect );
-            hash = hash * 31 + hash( resolve );
-            hash = hash * 31 + hash( aggregating );
+            hash = hash * 31 + Objects.hashCode( collect );
+            hash = hash * 31 + Objects.hashCode( resolve );
+            hash = hash * 31 + Objects.hashCode( aggregating );
             this.hashCode = hash;
         }
 
@@ -142,11 +143,6 @@ public class DefaultProjectArtifactsCache
             return hashCode;
         }
 
-        private static int hash( Object obj )
-        {
-            return obj != null ? obj.hashCode() : 0;
-        }
-
         @Override
         public boolean equals( Object o )
         {
@@ -162,22 +158,21 @@ public class DefaultProjectArtifactsCache
 
             CacheKey that = (CacheKey) o;
 
-            return eq( groupId, that.groupId ) && eq( artifactId, that.artifactId ) && eq( version, that.version ) 
-                && eq( dependencyArtifacts, that.dependencyArtifacts )
-                && eq( workspace, that.workspace ) && eq( localRepo, that.localRepo ) 
-                && RepositoryUtils.repositoriesEquals( repositories, that.repositories ) && eq( collect, that.collect ) 
-                && eq( resolve, that.resolve ) && aggregating == that.aggregating;
+            return Objects.equals( groupId, that.groupId ) && Objects.equals( artifactId, that.artifactId )
+                && Objects.equals( version, that.version )
+                && Objects.equals( dependencyArtifacts, that.dependencyArtifacts )
+                && Objects.equals( workspace, that.workspace ) 
+                && Objects.equals( localRepo, that.localRepo )
+                && RepositoryUtils.repositoriesEquals( repositories, that.repositories )
+                && Objects.equals( collect, that.collect ) 
+                && Objects.equals( resolve, that.resolve )
+                && aggregating == that.aggregating;
         }
-
-        private static <T> boolean eq( T s1, T s2 )
-        {
-            return s1 != null ? s1.equals( s2 ) : s2 == null;
-        }
-
     }
 
     protected final Map<Key, CacheRecord> cache = new ConcurrentHashMap<>();
 
+    @Override
     public Key createKey( MavenProject project, Collection<String> scopesToCollect,
         Collection<String> scopesToResolve, boolean aggregating, RepositorySystemSession session )
     {
@@ -185,6 +180,7 @@ public class DefaultProjectArtifactsCache
             aggregating, session );
     }
 
+    @Override
     public CacheRecord get( Key key )
         throws LifecycleExecutionException
     {
@@ -198,6 +194,7 @@ public class DefaultProjectArtifactsCache
         return cacheRecord;
     }
 
+    @Override
     public CacheRecord put( Key key, Set<Artifact> projectArtifacts )
     {
         Validate.notNull( projectArtifacts, "projectArtifacts cannot be null" );
@@ -220,6 +217,7 @@ public class DefaultProjectArtifactsCache
         }
     }
 
+    @Override
     public CacheRecord put( Key key, LifecycleExecutionException exception )
     {
         Validate.notNull( exception, "exception cannot be null" );
@@ -233,11 +231,13 @@ public class DefaultProjectArtifactsCache
         return record;
     }
 
+    @Override
     public void flush()
     {
         cache.clear();
     }
 
+    @Override
     public void register( MavenProject project, Key cacheKey, CacheRecord record )
     {
         // default cache does not track record usage