Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2013-10-02 10:09:22 +0000
committerUwe Stieber2013-10-02 10:09:22 +0000
commit80ebc946017a635e15879efd5770c6cd03e42208 (patch)
treeb38e6ca15507f1ec7d498b32e24fdfd7fbeff8ef /target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch
parent480dd32e10edea5885d856d9472796be86469e10 (diff)
downloadorg.eclipse.tcf-80ebc946017a635e15879efd5770c6cd03e42208.tar.gz
org.eclipse.tcf-80ebc946017a635e15879efd5770c6cd03e42208.tar.xz
org.eclipse.tcf-80ebc946017a635e15879efd5770c6cd03e42208.zip
Target Explorer: Make the path map server thread safe
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java
index b29d5c639..3ce3dc023 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java
@@ -14,6 +14,8 @@ import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
@@ -45,6 +47,8 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider;
* Path map service implementation.
*/
public class PathMapService extends AbstractService implements IPathMapService {
+ // Lock to handle multi thread access
+ private final Lock lock = new ReentrantLock();
/* (non-Javadoc)
* @see org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService#getPathMap(java.lang.Object)
@@ -54,6 +58,9 @@ public class PathMapService extends AbstractService implements IPathMapService {
Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
Assert.isNotNull(context);
+ // Acquire the lock before accessing the path mappings
+ lock.lock();
+
PathMapRule[] rules = null;
List<PathMapRule> rulesList = new ArrayList<PathMapRule>();
@@ -88,6 +95,9 @@ public class PathMapService extends AbstractService implements IPathMapService {
rules = rulesList.toArray(new PathMapRule[rulesList.size()]);
}
+ // Release the lock
+ lock.unlock();
+
return rules;
}
@@ -101,6 +111,9 @@ public class PathMapService extends AbstractService implements IPathMapService {
Assert.isNotNull(source);
Assert.isNotNull(destination);
+ // Acquire the lock before accessing the path mappings
+ lock.lock();
+
PathMapRule rule = null;
List<PathMapRule> rulesList = new ArrayList<PathMapRule>();
@@ -144,7 +157,10 @@ public class PathMapService extends AbstractService implements IPathMapService {
}
}
- return rule;
+ // Release the lock
+ lock.unlock();
+
+ return rule;
}
/* (non-Javadoc)
@@ -156,6 +172,9 @@ public class PathMapService extends AbstractService implements IPathMapService {
Assert.isNotNull(context);
Assert.isNotNull(rule);
+ // Acquire the lock before accessing the path mappings
+ lock.lock();
+
List<PathMapRule> rulesList = new ArrayList<PathMapRule>();
// Get the launch configuration for that peer model
@@ -183,6 +202,9 @@ public class PathMapService extends AbstractService implements IPathMapService {
});
}
}
+
+ // Release the lock
+ lock.unlock();
}
/**

Back to the top