Bug 579101 - Use ConcurrentHashMap for WorkspaceRoot's projectTable
Change-Id: I14cd87a08b31699f4fb27b5f92b8e791a58f0111
Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.resources/+/191507
Tested-by: Mickael Istria <mistria@redhat.com>
Reviewed-by: Mickael Istria <mistria@redhat.com>
diff --git a/bundles/org.eclipse.core.resources/META-INF/MANIFEST.MF b/bundles/org.eclipse.core.resources/META-INF/MANIFEST.MF
index a52bdf4..0ab8793 100644
--- a/bundles/org.eclipse.core.resources/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.core.resources/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.core.resources; singleton:=true
-Bundle-Version: 3.16.100.qualifier
+Bundle-Version: 3.16.200.qualifier
Bundle-Activator: org.eclipse.core.resources.ResourcesPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceRoot.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceRoot.java
index 547c692..0318b48 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceRoot.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceRoot.java
@@ -15,7 +15,8 @@
package org.eclipse.core.internal.resources;
import java.net.URI;
-import java.util.*;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.internal.utils.FileUtil;
import org.eclipse.core.internal.utils.Policy;
@@ -29,7 +30,7 @@
* that have been requested from this root. This maps project
* name strings to project handles.
*/
- private final Map<String, Project> projectTable = Collections.synchronizedMap(new HashMap<>(16));
+ private final Map<String, Project> projectTable = new ConcurrentHashMap<>(16);
/**
* Cache of the canonicalized platform location.
@@ -150,11 +151,7 @@
Assert.isLegal(projectPath.segmentCount() == ICoreConstants.PROJECT_SEGMENT_LENGTH, message);
//try to get the project using a canonical name
String canonicalName = projectPath.lastSegment();
- result = projectTable.get(canonicalName);
- if (result != null)
- return result;
- result = new Project(projectPath, workspace);
- projectTable.put(canonicalName, result);
+ result = projectTable.computeIfAbsent(canonicalName, n -> new Project(projectPath, workspace));
}
return result;
}