karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [1/3] karaf git commit: [KARAF-5340] Fix very suspicious calls with generics collections
Date Wed, 06 Sep 2017 06:18:22 GMT
Repository: karaf
Updated Branches:
  refs/heads/master b2d5c5b81 -> 1e5352271


[KARAF-5340] Fix very suspicious calls with generics collections

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

Branch: refs/heads/master
Commit: 1e53522714a647e4e9d3900a148b22a76c6479cb
Parents: 41efcf1
Author: Guillaume Nodet <gnodet@apache.org>
Authored: Wed Sep 6 08:17:13 2017 +0200
Committer: Guillaume Nodet <gnodet@apache.org>
Committed: Wed Sep 6 08:17:55 2017 +0200

----------------------------------------------------------------------
 .../karaf/tooling/utils/Dependency31Helper.java    | 15 ++++++++-------
 .../karaf/tooling/utils/LocalDependency.java       | 17 ++++++++++++-----
 2 files changed, 20 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/1e535227/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/Dependency31Helper.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/Dependency31Helper.java
b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/Dependency31Helper.java
index 2878c72..4a6c5d0 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/Dependency31Helper.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/Dependency31Helper.java
@@ -72,7 +72,7 @@ public class Dependency31Helper implements DependencyHelper {
     private final List<RemoteRepository> projectRepositories;
 
     // dependencies we are interested in
-    protected Set<LocalDependency> localDependencies;
+    protected Map<Artifact, LocalDependency> localDependencies;
     // log of what happened during search
     protected String treeListing;
 
@@ -92,8 +92,8 @@ public class Dependency31Helper implements DependencyHelper {
 	}
 
     @Override
-    public Set<LocalDependency> getLocalDependencies() {
-        return localDependencies;
+    public Collection<LocalDependency> getLocalDependencies() {
+        return localDependencies.values();
     }
 
     @Override
@@ -203,7 +203,7 @@ public class Dependency31Helper implements DependencyHelper {
         }
 
         // all the dependencies needed, with provided dependencies removed
-        private final Set<LocalDependency> localDependencies = new LinkedHashSet<>();
+        private final Map<Artifact, LocalDependency> localDependencies = new LinkedHashMap<>();
 
         // dependencies from ancestor, to be removed from localDependencies
         private final Set<Artifact> dependencies = new LinkedHashSet<>();
@@ -215,7 +215,7 @@ public class Dependency31Helper implements DependencyHelper {
                 scan(rootNode, child, Accept.ACCEPT, useTransitiveDependencies, false, "");
             }
             if (useTransitiveDependencies) {
-                localDependencies.removeAll(dependencies);
+                localDependencies.keySet().removeAll(dependencies);
             }
         }
 
@@ -231,12 +231,13 @@ public class Dependency31Helper implements DependencyHelper {
                     }
                 } else {
                     log.append(indent).append("local:").append(dependencyNode).append("\n");
-                    if (localDependencies.contains(dependencyNode.getDependency().getArtifact()))
{
+                    if (localDependencies.keySet().contains(dependencyNode.getDependency().getArtifact()))
{
                         log.append(indent).append("already in feature, returning:").append(dependencyNode).append("\n");
                         return;
                     }
                     // TODO resolve scope conflicts
-                    localDependencies.add(new LocalDependency(dependencyNode.getDependency().getScope(),
dependencyNode.getDependency().getArtifact(), parentNode.getDependency().getArtifact()));
+                    localDependencies.put(dependencyNode.getDependency().getArtifact(),
+                            new LocalDependency(dependencyNode.getDependency().getScope(),
dependencyNode.getDependency().getArtifact(), parentNode.getDependency().getArtifact()));
                     if (isFeature(dependencyNode) || !useTransitiveDependencies) {
                         isFromFeature = true;
                     }

http://git-wip-us.apache.org/repos/asf/karaf/blob/1e535227/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/LocalDependency.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/LocalDependency.java
b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/LocalDependency.java
index 7dc7e4d..a925ef1 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/LocalDependency.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/LocalDependency.java
@@ -16,6 +16,8 @@
  */
 package org.apache.karaf.tooling.utils;
 
+import java.util.Objects;
+
 public class LocalDependency {
 	private String scope;
 	private Object artifact;
@@ -38,14 +40,19 @@ public class LocalDependency {
 	public Object getParent() {
 		return parent;
 	}
-	
+
 	@Override
-	public int hashCode() {
-		return artifact.hashCode();
+	public boolean equals(Object o) {
+		if (this == o) return true;
+		if (o == null || getClass() != o.getClass()) return false;
+		LocalDependency that = (LocalDependency) o;
+		return Objects.equals(scope, that.scope) &&
+				Objects.equals(artifact, that.artifact) &&
+				Objects.equals(parent, that.parent);
 	}
 
 	@Override
-	public boolean equals(Object obj) {
-		return artifact.equals(obj);
+	public int hashCode() {
+		return Objects.hash(scope, artifact, parent);
 	}
 }


Mime
View raw message