--- a/test/langtools/jdk/jshell/ReplToolTesting.java Tue Jan 08 09:29:36 2019 +0100
+++ b/test/langtools/jdk/jshell/ReplToolTesting.java Tue Jan 08 16:31:27 2019 +0100
@@ -22,6 +22,7 @@
*/
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
@@ -126,6 +127,14 @@
cmdin.setInput(s);
}
+ public void closeCommandInput() {
+ try {
+ cmdin.close();
+ } catch (IOException ex) {
+ throw new IllegalStateException(ex);
+ }
+ }
+
public final static Pattern idPattern = Pattern.compile("^\\s+(\\d+)");
public Consumer<String> assertList() {
return s -> {
@@ -755,6 +764,8 @@
class WaitingTestingInputStream extends TestingInputStream {
+ private boolean closed;
+
@Override
synchronized void setInput(String s) {
super.setInput(s);
@@ -764,7 +775,7 @@
synchronized void waitForInput() {
boolean interrupted = false;
try {
- while (available() == 0) {
+ while (available() == 0 && !closed) {
try {
wait();
} catch (InterruptedException e) {
@@ -790,6 +801,12 @@
waitForInput();
return super.read(b, off, len);
}
+
+ @Override
+ public synchronized void close() throws IOException {
+ closed = true;
+ notify();
+ }
}
class PromptedCommandOutputStream extends OutputStream {