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
--- 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() {