Skip to content

Commit

Permalink
Change fileSystems to use ConcurrentHashMap
Browse files Browse the repository at this point in the history
See #1137
See #1114
  • Loading branch information
iloveeclipse committed Jan 24, 2024
1 parent a05b110 commit e9f9536
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
package org.eclipse.core.internal.filesystem;

import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.filesystem.IFileSystem;
Expand Down Expand Up @@ -43,7 +45,7 @@ public class InternalFileSystemCore implements IRegistryChangeListener {
* element for the extension. Once the file system has been created, the
* map contains the IFileSystem instance for that scheme.
*/
private HashMap<String, Object> fileSystems;
private ConcurrentMap<String, Object> fileSystems;

/**
* Returns the singleton instance of this class.
Expand Down Expand Up @@ -71,7 +73,7 @@ private InternalFileSystemCore() {
public IFileSystem getFileSystem(String scheme) throws CoreException {
if (scheme == null)
throw new NullPointerException();
final HashMap<String, Object> registry = getFileSystemRegistry();
final Map<String, Object> registry = getFileSystemRegistry();
Object result = registry.get(scheme);
if (result == null)
Policy.error(EFS.ERROR_INTERNAL, NLS.bind(Messages.noFileSystem, scheme));
Expand Down Expand Up @@ -129,9 +131,9 @@ public IFileStore getStore(URI uri) throws CoreException {
* Returns the fully initialized file system registry
* @return The file system registry
*/
private synchronized HashMap<String, Object> getFileSystemRegistry() {
private synchronized ConcurrentMap<String, Object> getFileSystemRegistry() {
if (fileSystems == null) {
fileSystems = new HashMap<>();
fileSystems = new ConcurrentHashMap<>();
IExtensionPoint point = RegistryFactory.getRegistry().getExtensionPoint(EFS.PI_FILE_SYSTEM, EFS.PT_FILE_SYSTEMS);
IExtension[] extensions = point.getExtensions();
for (IExtension extension : extensions) {
Expand Down

0 comments on commit e9f9536

Please sign in to comment.