Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Tanasenko2014-10-05 13:18:43 -0400
committerAnton Tanasenko2014-10-08 14:30:31 -0400
commit796e63741b8e0738b2b674f7fb5f81b18e3c1d72 (patch)
tree995d07ad04d46887dd16487cb224fa1b74230d89 /org.eclipse.m2e.core
parent7bc157889cb8cb4cc6c036a8467c0d7acd8e1241 (diff)
downloadm2e-core-796e63741b8e0738b2b674f7fb5f81b18e3c1d72.tar.gz
m2e-core-796e63741b8e0738b2b674f7fb5f81b18e3c1d72.tar.xz
m2e-core-796e63741b8e0738b2b674f7fb5f81b18e3c1d72.zip
446085 Project registry inconsistencies with more than 1 same-gav
project is present Change-Id: I06ae6d36b234a36196b807c1fe8e59f5f137e609 Signed-off-by: Anton Tanasenko <atg.sleepless@gmail.com>
Diffstat (limited to 'org.eclipse.m2e.core')
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/BasicProjectRegistry.java13
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MutableProjectRegistry.java19
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistry.java2
3 files changed, 23 insertions, 11 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/BasicProjectRegistry.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/BasicProjectRegistry.java
index daa2ad40..cae366e4 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/BasicProjectRegistry.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/BasicProjectRegistry.java
@@ -32,14 +32,14 @@ import org.eclipse.m2e.core.internal.MavenPluginActivator;
*/
abstract class BasicProjectRegistry implements Serializable {
- private static final long serialVersionUID = 5542512601401896748L;
+ private static final long serialVersionUID = 6232274446642339434L;
private final String m2e_version = MavenPluginActivator.getQualifiedVersion();
/**
* Maps ArtifactKey to IFile of the POM file that defines this artifact.
*/
- protected final Map<ArtifactKey, IFile> workspaceArtifacts = new HashMap<>();
+ protected final Map<ArtifactKey, Set<IFile>> workspaceArtifacts = new HashMap<>();
/**
* Maps IFile to MavenProjectFacade
@@ -115,11 +115,11 @@ abstract class BasicProjectRegistry implements Serializable {
}
public MavenProjectFacade getProjectFacade(String groupId, String artifactId, String version) {
- IFile path = workspaceArtifacts.get(new ArtifactKey(groupId, artifactId, version, null));
- if(path == null) {
+ Set<IFile> paths = workspaceArtifacts.get(new ArtifactKey(groupId, artifactId, version, null));
+ if(paths == null || paths.isEmpty()) {
return null;
}
- return workspacePoms.get(path);
+ return workspacePoms.get(paths.iterator().next());
}
/**
@@ -130,7 +130,8 @@ abstract class BasicProjectRegistry implements Serializable {
}
public IFile getWorkspaceArtifact(ArtifactKey key) {
- return workspaceArtifacts.get(key);
+ Set<IFile> paths = workspaceArtifacts.get(key);
+ return paths == null || paths.isEmpty() ? null : paths.iterator().next();
}
protected void clear() {
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MutableProjectRegistry.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MutableProjectRegistry.java
index 0213924e..1804b760 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MutableProjectRegistry.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MutableProjectRegistry.java
@@ -34,7 +34,7 @@ import org.eclipse.m2e.core.embedder.ArtifactKey;
*/
public class MutableProjectRegistry extends BasicProjectRegistry implements IProjectRegistry {
- private static final long serialVersionUID = -4106047696261024741L;
+ private static final long serialVersionUID = 4879169945594340946L;
private final ProjectRegistry parent;
@@ -60,14 +60,22 @@ public class MutableProjectRegistry extends BasicProjectRegistry implements IPro
// remove
MavenProjectFacade oldFacade = workspacePoms.remove(pom);
if(oldFacade != null) {
- workspaceArtifacts.remove(oldFacade.getArtifactKey());
+ Set<IFile> paths = workspaceArtifacts.get(oldFacade.getArtifactKey());
+ if(paths != null) {
+ paths.remove(pom);
+ }
}
if(facade != null) {
// Add the project to workspaceProjects map
workspacePoms.put(pom, facade);
// Add the project to workspaceArtifacts map
- workspaceArtifacts.put(facade.getArtifactKey(), pom);
+ Set<IFile> paths = workspaceArtifacts.get(facade.getArtifactKey());
+ if(paths == null) {
+ paths = new LinkedHashSet<IFile>();
+ workspaceArtifacts.put(facade.getArtifactKey(), paths);
+ }
+ paths.add(pom);
}
}
@@ -84,7 +92,10 @@ public class MutableProjectRegistry extends BasicProjectRegistry implements IPro
// Remove the project from workspaceArtifacts map
if(mavenProject != null) {
- workspaceArtifacts.remove(mavenProject);
+ Set<IFile> paths = workspaceArtifacts.get(mavenProject);
+ if(paths != null) {
+ paths.remove(pom);
+ }
}
if(facade != null) {
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistry.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistry.java
index 0ea78e23..12f612ff 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistry.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistry.java
@@ -31,7 +31,7 @@ import org.eclipse.m2e.core.project.MavenProjectChangedEvent;
*/
public class ProjectRegistry extends BasicProjectRegistry implements Serializable, IProjectRegistry {
- private static final long serialVersionUID = -5813062417528479711L;
+ private static final long serialVersionUID = 7296606601386638800L;
private transient int version;

Back to the top