8166890: JShell: locks forever when input is piped
authorjlahoda
Tue, 11 Oct 2016 12:29:39 +0200
changeset 41518 8fd0057d88f3
parent 41517 ae82072ecfa7
child 41519 612f31a9b42b
8166890: JShell: locks forever when input is piped Summary: StopDetectingInputStream.setState must not override the state if the stream is closed. Reviewed-by: rfield, shinyafox
langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java	Tue Oct 11 10:56:09 2016 +0100
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java	Tue Oct 11 12:29:39 2016 +0200
@@ -77,9 +77,7 @@
                 } catch (IOException ex) {
                     errorHandler.accept(ex);
                 } finally {
-                    synchronized (StopDetectingInputStream.this) {
-                        state = StopDetectingInputStream.State.CLOSED;
-                    }
+                    shutdown();
                 }
             }
         };
@@ -140,8 +138,10 @@
     }
 
     public synchronized void setState(State state) {
-        this.state = state;
-        notifyAll();
+        if (this.state != State.CLOSED) {
+            this.state = state;
+            notifyAll();
+        }
     }
 
     private synchronized State waitInputNeeded() {