Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronize the access to LRUCache #978

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
Expand Down Expand Up @@ -94,11 +95,11 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett

private static final int FIND_RESOURCES_CACHE_SIZE = 100;

private LRUCache<URI, IResource[]> workspaceRootFindContainersForLocationURICache = new LRUCache<>(
FIND_RESOURCES_CACHE_SIZE);
private LRUCache<URI, IResource[]> workspaceRootFindFilesForLocationURICache = new LRUCache<>(
FIND_RESOURCES_CACHE_SIZE);
private HashMap<IProject, LRUCache<IPath, List<IResource>>> findPathInProjectCache = new HashMap<>();
private Map<URI, IResource[]> workspaceRootFindContainersForLocationURICache = Collections.synchronizedMap(new LRUCache<>(
FIND_RESOURCES_CACHE_SIZE));
private Map<URI, IResource[]> workspaceRootFindFilesForLocationURICache = Collections.synchronizedMap(new LRUCache<>(
FIND_RESOURCES_CACHE_SIZE));
private Map<IProject, LRUCache<IPath, List<IResource>>> Collections.synchronizedMap(findPathInProjectCache = new HashMap<>());

//String pathStr, URI baseURI -> URI
private static class MappedURIKey {
Expand Down Expand Up @@ -144,11 +145,11 @@ public boolean equals(Object obj) {
}

// Caches the result of determineMappedURI
private LRUCache<MappedURIKey, URI> mappedURICache = new LRUCache<>(FIND_RESOURCES_CACHE_SIZE);
private Map<MappedURIKey, URI> mappedURICache = Collections.synchronizedMap(new LRUCache<>(FIND_RESOURCES_CACHE_SIZE));
// Caches the result of getFilesystemLocation
private LRUCache<URI, IPath> fileSystemLocationCache = new LRUCache<>(FIND_RESOURCES_CACHE_SIZE);
private Map<URI, IPath> fileSystemLocationCache = Collections.synchronizedMap(new LRUCache<>(FIND_RESOURCES_CACHE_SIZE));
// Caches the result of new File(pathname).exists()
private LRUCache<IPath, Boolean> pathExistsCache = new LRUCache<>(FIND_RESOURCES_CACHE_SIZE);
private Map<IPath, Boolean> pathExistsCache = Collections.synchronizedMap(new LRUCache<>(FIND_RESOURCES_CACHE_SIZE));

/** @since 8.2 */
protected EFSExtensionProvider efsProvider = null;
Expand Down
Loading