Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2019-04-23 18:53:36 +0000
committerAndrey Loskutov2019-04-24 14:23:37 +0000
commite464979869b087a1af7c21fa4b54136db563bda4 (patch)
treeddc12fe6c41d23dddfb72223cbe969809fb77188 /org.eclipse.debug.ui/ui
parent3603b78f540b0ed6f0927465e8a3202ae6acf698 (diff)
downloadeclipse.platform.debug-e464979869b087a1af7c21fa4b54136db563bda4.tar.gz
eclipse.platform.debug-e464979869b087a1af7c21fa4b54136db563bda4.tar.xz
eclipse.platform.debug-e464979869b087a1af7c21fa4b54136db563bda4.zip
Bug 546641 - [console] ProcessConsole InputReadJob is not cancelableI20190425-0030I20190424-1800
Change-Id: I453380da668bc5d04e2f90469a16d2ce37d1e90d Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de> Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.debug.ui/ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java32
1 files changed, 27 insertions, 5 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java
index 0af92d15a..085cb0f80 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java
@@ -707,11 +707,32 @@ public class ProcessConsole extends IOConsole implements IConsole, IDebugEventSe
private IStreamsProxy streamsProxy;
+ /**
+ * The {@link InputStream} this job is currently reading from or maybe blocking
+ * on. May be <code>null</code>.
+ */
+ private InputStream readingStream;
+
InputReadJob(IStreamsProxy streamsProxy) {
super("Process Console Input Job"); //$NON-NLS-1$
this.streamsProxy = streamsProxy;
}
+ @Override
+ protected void canceling() {
+ super.canceling();
+ if (readingStream != null) {
+ // Close stream or job may not be able to cancel.
+ // This is primary for IOConsoleInputStream because there is no guarantee an
+ // arbitrary InputStream will release a blocked read() on close.
+ try {
+ readingStream.close();
+ } catch (IOException e) {
+ DebugUIPlugin.log(e);
+ }
+ }
+ }
+
@Override
public boolean belongsTo(Object family) {
return ProcessConsole.class == family;
@@ -723,12 +744,12 @@ public class ProcessConsole extends IOConsole implements IConsole, IDebugEventSe
try {
byte[] b = new byte[1024];
int read = 0;
- while (read >= 0) {
- InputStream input = fInput;
- if (input == null) {
+ while (read >= 0 && !monitor.isCanceled()) {
+ readingStream = fInput;
+ if (readingStream == null) {
break;
}
- read = input.read(b);
+ read = readingStream.read(b);
if (read > 0) {
String s;
if (encoding != null) {
@@ -742,7 +763,8 @@ public class ProcessConsole extends IOConsole implements IConsole, IDebugEventSe
} catch (IOException e) {
DebugUIPlugin.log(e);
}
- return Status.OK_STATUS;
+ readingStream = null;
+ return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
}
}

Back to the top