Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Chen2012-02-28 22:30:05 -0500
committerWilliam Chen2012-02-28 22:31:13 -0500
commit9a3c1d5f78d8e019f8757fc26d4f9a87ffca0a65 (patch)
treeae42a5bf2755c03ded76d24d30f93324be3ff2de
parentbf92a80ecb29c91863cfb20bbd4a36e89a4fb232 (diff)
downloadorg.eclipse.tcf-9a3c1d5f78d8e019f8757fc26d4f9a87ffca0a65.tar.gz
org.eclipse.tcf-9a3c1d5f78d8e019f8757fc26d4f9a87ffca0a65.tar.xz
org.eclipse.tcf-9a3c1d5f78d8e019f8757fc26d4f9a87ffca0a65.zip
Target Explorer: [372630] Launching a process ends up with an
IOException.
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/launcher/ProcessStreamsListener.java36
1 files changed, 14 insertions, 22 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/launcher/ProcessStreamsListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/launcher/ProcessStreamsListener.java
index 5506259e2..7263bebdc 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/launcher/ProcessStreamsListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/launcher/ProcessStreamsListener.java
@@ -21,6 +21,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IToken;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.services.IProcesses;
@@ -42,8 +43,10 @@ import org.eclipse.tcf.util.TCFTask;
* Remote process streams listener implementation.
*/
public class ProcessStreamsListener implements IStreams.StreamsListener, IProcessContextAwareListener {
- // The parent process launcher instance
- private final ProcessLauncher parent;
+ // The channel instance
+ /* default */ IChannel channel;
+ // The streams service instance
+ /* default */ IStreams svcStreams;
// The remote process context
private IProcesses.ProcessContext context;
// The list of registered stream data receivers
@@ -230,8 +233,6 @@ public class ProcessStreamsListener implements IStreams.StreamsListener, IProces
// Store the callback instance
this.callback = callback;
- // Mark the runnable as stopped
- stopped = true;
}
/**
@@ -275,8 +276,6 @@ public class ProcessStreamsListener implements IStreams.StreamsListener, IProces
public void run() {
// Create a snapshot of the receivers
final StreamsDataReceiver[] receivers = this.receivers.toArray(new StreamsDataReceiver[this.receivers.size()]);
- // Get the service instance from the parent
- final IStreams svcStreams = getParent().getSvcStreams();
// Run until stopped and the streams service is available
while (!isStopped() && svcStreams != null) {
@@ -329,6 +328,12 @@ public class ProcessStreamsListener implements IStreams.StreamsListener, IProces
// Mark the runnable definitely stopped
stopped = true;
}
+ // Make sure that data receivers are disposed before leaving the thread.
+ // This will closes the PipedOutputStream wrapped by the writer in the data receivers,
+ // thus the PipedInputStream read an EOS and terminate gracefully.
+ for(StreamsDataReceiver receiver:receivers) {
+ receiver.dispose();
+ }
}
/**
@@ -348,7 +353,7 @@ public class ProcessStreamsListener implements IStreams.StreamsListener, IProces
Assert.isTrue(!Protocol.isDispatchThread());
// Create the task object
- TCFTask<ReadData> task = new TCFTask<ReadData>(getParent().getChannel()) {
+ TCFTask<ReadData> task = new TCFTask<ReadData>(channel) {
@Override
public void run() {
service.read(streamId, size, new IStreams.DoneRead() {
@@ -516,9 +521,6 @@ public class ProcessStreamsListener implements IStreams.StreamsListener, IProces
return;
}
- // Get the service instance from the parent
- final IStreams svcStreams = getParent().getSvcStreams();
-
// Create the data buffer instance
final char[] buffer = new char[1024];
@@ -619,16 +621,8 @@ public class ProcessStreamsListener implements IStreams.StreamsListener, IProces
*/
public ProcessStreamsListener(ProcessLauncher parent) {
Assert.isNotNull(parent);
- this.parent = parent;
- }
-
- /**
- * Returns the parent process launcher instance.
- *
- * @return The parent process launcher instance.
- */
- protected final ProcessLauncher getParent() {
- return parent;
+ this.channel = parent.getChannel();
+ this.svcStreams = parent.getSvcStreams();
}
/**
@@ -655,8 +649,6 @@ public class ProcessStreamsListener implements IStreams.StreamsListener, IProces
@Override
protected void internalDone(final Object caller, final IStatus status) {
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- // Get the service instance from the parent
- IStreams svcStreams = getParent().getSvcStreams();
// Unsubscribe the streams listener from the service
svcStreams.unsubscribe(IProcesses.NAME, finStreamsListener, new IStreams.DoneUnsubscribe() {
@Override

Back to the top