changeset 3698:47a06846f4a4

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
author jlahoda
date Tue, 11 Oct 2016 12:29:39 +0200
parents 5adb61e143dc
children 9e9cd74c2787
files src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java	Tue Oct 11 10:56:09 2016 +0100
+++ b/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() {