Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2013-08-31 07:55:11 +0000
committerUwe Stieber2013-08-31 07:55:46 +0000
commit91db3174c21b7435c234dc8baf35f62cbd8caa82 (patch)
treea9c33c04e9cf927f76a939cd27869f158ab379b8 /target_explorer
parent92a40db5b76a5622c12bd3bfc6f3ec5b61390fc3 (diff)
downloadorg.eclipse.tcf-91db3174c21b7435c234dc8baf35f62cbd8caa82.tar.gz
org.eclipse.tcf-91db3174c21b7435c234dc8baf35f62cbd8caa82.tar.xz
org.eclipse.tcf-91db3174c21b7435c234dc8baf35f62cbd8caa82.zip
Target Explorer: Fix applying the path map on open channel may hang up the UI as TCFLaunch#launchConfigurationChanged is triggered in the TCF event dispatch thread
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/viewer/LaunchNavigatorContentProvider.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/ChannelManager.java73
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AdapterFactory.java21
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java2
5 files changed, 71 insertions, 31 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/viewer/LaunchNavigatorContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/viewer/LaunchNavigatorContentProvider.java
index 61bdd7f79..a78aaea4e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/viewer/LaunchNavigatorContentProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/viewer/LaunchNavigatorContentProvider.java
@@ -253,7 +253,9 @@ public class LaunchNavigatorContentProvider implements ITreeContentProvider, IEv
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
- ((TreeViewer)viewer).refresh((isRootNodeVisible() ? model.getRootNode() : model.getModelRoot()), true);
+ if (viewer.getControl() != null && !viewer.getControl().isDisposed()) {
+ ((TreeViewer)viewer).refresh((isRootNodeVisible() ? model.getRootNode() : model.getModelRoot()), true);
+ }
}
});
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java
index 792d5a08b..947244953 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java
@@ -21,6 +21,8 @@ public interface IPathMapService extends IService {
/**
* Return the configured (object) path mappings for the given context.
+ * <p>
+ * <b>Note:</b> This method must be called from outside the TCF event dispatch thread.
*
* @param context The context. Must not be <code>null</code>.
* @return The configured path map or <code>null</code>.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/ChannelManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/ChannelManager.java
index 5a9a96445..9177301eb 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/ChannelManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/ChannelManager.java
@@ -91,37 +91,58 @@ public final class ChannelManager extends PlatformObject implements IChannelMana
final IPathMap svc = channel.getRemoteService(IPathMap.class);
if (service != null && svc != null) {
// Get the configured path maps
- final PathMapRule[] configuredMap = service.getPathMap(peer);
- if (configuredMap != null && configuredMap.length > 0) {
- // Get the old path maps first. Keep path map rules not coming from us
- svc.get(new IPathMap.DoneGet() {
- @Override
- public void doneGet(IToken token, Exception e, PathMapRule[] map) {
- // Merge the maps to a new list
- List<PathMapRule> rules = new ArrayList<PathMapRule>();
-
- if (map != null && map.length > 0) {
- for (PathMapRule rule : map) {
- if (rule.getID() == null || !rule.getID().startsWith(service.getClientID())) {
- rules.add(rule);
+ final AtomicReference<PathMapRule[]> configuredMap = new AtomicReference<PathMapRule[]>();
+ // The runnable to execute within the TCF event dispatch thread once
+ // the configured path map has been retrieved from the launch configuration.
+ final Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ if (configuredMap.get() != null && configuredMap.get().length > 0) {
+ // Get the old path maps first. Keep path map rules not coming from us
+ svc.get(new IPathMap.DoneGet() {
+ @Override
+ public void doneGet(IToken token, Exception e, PathMapRule[] map) {
+ // Merge the maps to a new list
+ List<PathMapRule> rules = new ArrayList<PathMapRule>();
+
+ if (map != null && map.length > 0) {
+ for (PathMapRule rule : map) {
+ if (rule.getID() == null || !rule.getID().startsWith(service.getClientID())) {
+ rules.add(rule);
+ }
+ }
}
- }
- }
- rules.addAll(Arrays.asList(configuredMap));
- if (!rules.isEmpty()) {
- svc.set(rules.toArray(new PathMapRule[rules.size()]), new IPathMap.DoneSet() {
- @Override
- public void doneSet(IToken token, Exception e) {
+ rules.addAll(Arrays.asList(configuredMap.get()));
+ if (!rules.isEmpty()) {
+ svc.set(rules.toArray(new PathMapRule[rules.size()]), new IPathMap.DoneSet() {
+ @Override
+ public void doneSet(IToken token, Exception e) {
+ done.doneOpenChannel(error, channel);
+ }
+ });
+ } else {
done.doneOpenChannel(error, channel);
}
- });
- }
+ }
+ });
+ } else {
+ done.doneOpenChannel(error, channel);
}
- });
- } else {
- done.doneOpenChannel(error, channel);
- }
+ }
+ };
+
+ // Getting the path map from the launch configuration must happen
+ // outside the TCF dispatch thread as it may trigger the launch
+ // configuration change listeners.
+ Thread thread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ configuredMap.set(service.getPathMap(peer));
+ Protocol.invokeLater(runnable);
+ }
+ });
+ thread.start();
} else {
done.doneOpenChannel(error, channel);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AdapterFactory.java
index 44fdd98b3..e8c6849ba 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AdapterFactory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AdapterFactory.java
@@ -11,6 +11,7 @@ package org.eclipse.tcf.te.tcf.launch.core.internal.adapters;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.debug.core.DebugPlugin;
@@ -83,7 +84,7 @@ public class AdapterFactory implements IAdapterFactory {
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
*/
@Override
- public Object getAdapter(Object adaptableObject, Class adapterType) {
+ public Object getAdapter(final Object adaptableObject, final Class adapterType) {
if (adaptableObject instanceof ILaunch) {
if (IStepContext.class.equals(adapterType)) {
// Lookup the adapter
@@ -111,9 +112,21 @@ public class AdapterFactory implements IAdapterFactory {
}
}
else if (adaptableObject instanceof IPeer) {
- ILocatorModelLookupService service = Model.getModel().getService(ILocatorModelLookupService.class);
- IPeerModel peerModel = service != null ? service.lkupPeerModelById(((IPeer)adaptableObject).getID()) : null;
- if (peerModel != null) return getAdapter(peerModel, adapterType);
+ final ILocatorModelLookupService service = Model.getModel().getService(ILocatorModelLookupService.class);
+ final AtomicReference<IPeerModel> peerModel = new AtomicReference<IPeerModel>();
+
+ if (service != null) {
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ peerModel.set(service.lkupPeerModelById(((IPeer)adaptableObject).getID()));
+ }
+ };
+ if (Protocol.isDispatchThread()) runnable.run();
+ else Protocol.invokeAndWait(runnable);
+ }
+
+ if (peerModel.get() != null) return getAdapter(peerModel.get(), adapterType);
}
return null;
}
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 8a2fcc88a..1d19733a2 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
@@ -15,6 +15,7 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.services.IPathMap;
import org.eclipse.tcf.services.IPathMap.PathMapRule;
import org.eclipse.tcf.te.runtime.services.AbstractService;
@@ -30,6 +31,7 @@ public class PathMapService extends AbstractService implements IPathMapService {
*/
@Override
public PathMapRule[] getPathMap(Object context) {
+ Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
Assert.isNotNull(context);
PathMapRule[] rules = null;

Back to the top