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>
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 56464eb..1b94147 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 @@
/**
* 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 @@
}
@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);
}
}