Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2021-07-13 13:19:23 +0000
committerAndrey Loskutov2021-07-15 07:43:15 +0000
commit57902f262f078044d0bbe8921162b6473869eff5 (patch)
tree32bbac979625d49997ec3aa39c0904929a40cb73
parent5a96d5f04de74af3fc4692e48305360b1e03d9d7 (diff)
downloadeclipse.platform.debug-57902f262f078044d0bbe8921162b6473869eff5.tar.gz
eclipse.platform.debug-57902f262f078044d0bbe8921162b6473869eff5.tar.xz
eclipse.platform.debug-57902f262f078044d0bbe8921162b6473869eff5.zip
Bug 574818 - Deadlock in IOConsoleInputStream.close
Avoid calling into console.streamClosed(this) holding the lock on the stream. Change-Id: I91de4be61d6da666425c0d70e772eb6137ef2d3a Signed-off-by: Andrey Loskutov <loskutov@gmx.de> Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.debug/+/183022 Tested-by: Platform Bot <platform-bot@eclipse.org>
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleInputStream.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleInputStream.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleInputStream.java
index 56464eba5..1b94147f3 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleInputStream.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleInputStream.java
@@ -56,7 +56,7 @@ public class IOConsoleInputStream extends InputStream {
/**
* Flag to indicate that the stream has been closed.
*/
- private boolean closed = false;
+ private volatile boolean closed;
/**
* The console that this stream is connected to.
@@ -251,13 +251,19 @@ public class IOConsoleInputStream extends InputStream {
}
@Override
- public synchronized void close() throws IOException {
+ public void close() throws IOException {
if(closed) {
// Closeable#close() has no effect if already closed
return;
}
- closed = true;
- notifyAll();
+ synchronized (this) {
+ if (closed) {
+ return;
+ }
+ closed = true;
+ notifyAll();
+ }
+ // Locked in the console
console.streamClosed(this);
}
}

Back to the top