summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorChandler Zhang2012-11-16 10:47:52 (EST)
committer Igor Fedorenko2012-12-16 09:06:21 (EST)
commit78ec4981632aa8781f2924d72dee947bc3348fc8 (patch)
tree55641752a085b69ee4c03bef837146b49ef19258
parent20707859f37a73e10e91b6beae1a43b371af4640 (diff)
downloadm2e-core-78ec4981632aa8781f2924d72dee947bc3348fc8.zip
m2e-core-78ec4981632aa8781f2924d72dee947bc3348fc8.tar.gz
m2e-core-78ec4981632aa8781f2924d72dee947bc3348fc8.tar.bz2
394480 Eliminate duplicated MavenUpdateRequests
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryRefreshJob.java5
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/MavenUpdateRequest.java27
2 files changed, 29 insertions, 3 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryRefreshJob.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryRefreshJob.java
index fff94db..261d2ef 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryRefreshJob.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryRefreshJob.java
@@ -13,7 +13,6 @@ package org.eclipse.m2e.core.internal.project.registry;
import java.util.ArrayList;
import java.util.LinkedHashSet;
-import java.util.List;
import java.util.Set;
import org.slf4j.Logger;
@@ -50,7 +49,7 @@ public class ProjectRegistryRefreshJob extends Job implements IResourceChangeLis
private static final int DELTA_FLAGS = IResourceDelta.CONTENT | IResourceDelta.MOVED_FROM | IResourceDelta.MOVED_TO
| IResourceDelta.COPIED_FROM | IResourceDelta.REPLACED;
- private final List<MavenUpdateRequest> queue = new ArrayList<MavenUpdateRequest>();
+ private final Set<MavenUpdateRequest> queue = new LinkedHashSet<MavenUpdateRequest>();
private final ProjectRegistryManager manager;
@@ -103,7 +102,7 @@ public class ProjectRegistryRefreshJob extends Job implements IResourceChangeLis
log.info("{} was canceled", getClass().getName());
} catch (StaleMutableProjectRegistryException e) {
synchronized(this.queue) {
- this.queue.addAll(0, requests);
+ this.queue.addAll(requests);
if(!this.queue.isEmpty()) {
schedule(SCHEDULE_DELAY);
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/MavenUpdateRequest.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/MavenUpdateRequest.java
index 0220902..1dbcd8c 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/MavenUpdateRequest.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/MavenUpdateRequest.java
@@ -117,5 +117,32 @@ public class MavenUpdateRequest {
return sb.toString();
}
+
+ @Override
+ public boolean equals(Object object) {
+ if( this == object)
+ return true;
+
+ if(object == null)
+ return false;
+
+ if(! (object instanceof MavenUpdateRequest))
+ return false;
+
+ MavenUpdateRequest request = (MavenUpdateRequest)object;
+ if(this.offline == request.offline && this.forceDependencyUpdate == request.forceDependencyUpdate && this.pomFiles.equals(request.pomFiles))
+ return true;
+
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+ result = result * 31 + (this.offline ? 1:0);
+ result = result * 31 + (this.forceDependencyUpdate? 1:0);
+ result = result * 31 + this.pomFiles.hashCode();
+ return result;
+ }
}