Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2014-04-30 08:57:57 -0400
committerUwe Stieber2014-04-30 08:57:57 -0400
commit8d98a135232bdda3a68252e85a980d5e0cfd2df6 (patch)
tree21c647b55b043e20483a77236d26ca22b04540cd
parentc522fda5a8d0ffce3481e1e3e83ea9d3c0b7ccda (diff)
downloadorg.eclipse.tcf-8d98a135232bdda3a68252e85a980d5e0cfd2df6.tar.gz
org.eclipse.tcf-8d98a135232bdda3a68252e85a980d5e0cfd2df6.tar.xz
org.eclipse.tcf-8d98a135232bdda3a68252e85a980d5e0cfd2df6.zip
Target Explorer: Fix Illegal Thread Access invoking callback from PathMapService.applyPathMap
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java19
1 files changed, 13 insertions, 6 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 df979efa0..bd087b096 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
@@ -33,12 +33,14 @@ import org.eclipse.tcf.protocol.IToken;
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.callback.AsyncCallbackCollector;
import org.eclipse.tcf.te.runtime.callback.Callback;
import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tcf.te.runtime.services.AbstractService;
import org.eclipse.tcf.te.runtime.services.ServiceManager;
import org.eclipse.tcf.te.runtime.utils.StatusHelper;
import org.eclipse.tcf.te.tcf.core.Tcf;
+import org.eclipse.tcf.te.tcf.core.async.CallbackInvocationDelegate;
import org.eclipse.tcf.te.tcf.core.interfaces.IPathMapGeneratorService;
import org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService;
import org.eclipse.tcf.te.tcf.launch.core.activator.CoreBundleActivator;
@@ -315,6 +317,11 @@ public class PathMapService extends AbstractService implements IPathMapService {
if (peer == null && context instanceof IPeerNode) peer = ((IPeerNode)context).getPeer();
if (peer == null && context instanceof IPeerNodeProvider && ((IPeerNodeProvider)context).getPeerNode() != null) peer = ((IPeerNodeProvider)context).getPeerNode().getPeer();
+ // Make sure that the callback is invoked in the TCF dispatch thread
+ final AsyncCallbackCollector collector = new AsyncCallbackCollector(callback, new CallbackInvocationDelegate());
+ final ICallback innerCallback = new AsyncCallbackCollector.SimpleCollectorCallback(collector);
+ collector.initDone();
+
if (peer != null) {
final IChannel channel = Tcf.getChannelManager().getChannel(peer);
if (channel != null && IChannel.STATE_OPEN == channel.getState()) {
@@ -345,29 +352,29 @@ public class PathMapService extends AbstractService implements IPathMapService {
set(rules, svc, new IPathMap.DoneSet() {
@Override
public void doneSet(IToken token, Exception error) {
- callback.done(PathMapService.this, StatusHelper.getStatus(error));
+ innerCallback.done(PathMapService.this, StatusHelper.getStatus(error));
}
});
} else {
- callback.done(PathMapService.this, Status.OK_STATUS);
+ innerCallback.done(PathMapService.this, Status.OK_STATUS);
}
}
});
} else {
- callback.done(PathMapService.this, Status.OK_STATUS);
+ innerCallback.done(PathMapService.this, Status.OK_STATUS);
}
}
};
Protocol.invokeLater(runnable);
} else {
- callback.done(PathMapService.this, Status.OK_STATUS);
+ innerCallback.done(PathMapService.this, Status.OK_STATUS);
}
} else {
- callback.done(PathMapService.this, Status.OK_STATUS);
+ innerCallback.done(PathMapService.this, Status.OK_STATUS);
}
} else {
- callback.done(PathMapService.this, Status.OK_STATUS);
+ innerCallback.done(PathMapService.this, Status.OK_STATUS);
}
}

Back to the top