mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-18 22:45:23 +02:00
[368454] provide thread safety for cachedRemoteFiles hashmap
This commit is contained in:
parent
9df17e06e3
commit
0ea623ad32
2 changed files with 26 additions and 7 deletions
|
@ -1154,10 +1154,9 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
|
||||||
if (newConfig instanceof IFileServiceSubSystemConfiguration) {
|
if (newConfig instanceof IFileServiceSubSystemConfiguration) {
|
||||||
IHost host = getHost();
|
IHost host = getHost();
|
||||||
IFileServiceSubSystemConfiguration config = (IFileServiceSubSystemConfiguration) newConfig;
|
IFileServiceSubSystemConfiguration config = (IFileServiceSubSystemConfiguration) newConfig;
|
||||||
// file subsystem specific bits
|
|
||||||
synchronized (_cachedRemoteFiles){
|
clearRemoteFileCache();
|
||||||
_cachedRemoteFiles.clear();
|
|
||||||
}
|
|
||||||
_languageUtilityFactory = null;
|
_languageUtilityFactory = null;
|
||||||
setFileService(config.getFileService(host));
|
setFileService(config.getFileService(host));
|
||||||
setHostFileToRemoteFileAdapter(config.getHostFileAdapter());
|
setHostFileToRemoteFileAdapter(config.getHostFileAdapter());
|
||||||
|
|
|
@ -124,9 +124,20 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
|
||||||
protected ArrayList _searchHistory;
|
protected ArrayList _searchHistory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All created IRemoteFiles are mapped in a cache for quick retrieval.
|
* The _cachedRemoteFiles map is used to store queried IRemoteFiles
|
||||||
* This is a HashMap so any access to it needs to be synchronized otherwise
|
* for quick retrieval. This is a HashMap so any access to it needs
|
||||||
* thread-safety could be compromised.
|
* to be synchronized; otherwise thread-safety could be compromised.
|
||||||
|
*
|
||||||
|
* The _cachedRemoteFiles HashMap should be synchronized on like this:
|
||||||
|
* <code>
|
||||||
|
* synchronized (_cachedRemoteFiles){
|
||||||
|
* // call to _cachedRemoteFiles
|
||||||
|
* ...
|
||||||
|
* }
|
||||||
|
* </code>
|
||||||
|
* @deprecated going forward, this field will be non-API. A new
|
||||||
|
* protected clearRemoteFileCache() method allows cache
|
||||||
|
* clearing.
|
||||||
*/
|
*/
|
||||||
protected HashMap _cachedRemoteFiles = new HashMap();
|
protected HashMap _cachedRemoteFiles = new HashMap();
|
||||||
|
|
||||||
|
@ -1395,6 +1406,15 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 3.3
|
||||||
|
*/
|
||||||
|
protected void clearRemoteFileCache(){
|
||||||
|
synchronized (_cachedRemoteFiles){
|
||||||
|
_cachedRemoteFiles.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void communicationsStateChange(CommunicationsEvent e)
|
public void communicationsStateChange(CommunicationsEvent e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue