Skip to content

Commit 42350af

Browse files
committed
Make sure EmbeddedCli fails fast
1 parent 98a7fa6 commit 42350af

File tree

1 file changed

+6
-3
lines changed
  • x-pack/plugin/sql/qa/server/src/main/java/org/elasticsearch/xpack/sql/qa/cli

1 file changed

+6
-3
lines changed

x-pack/plugin/sql/qa/server/src/main/java/org/elasticsearch/xpack/sql/qa/cli/EmbeddedCli.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public void close() throws IOException {
215215
out.flush();
216216
List<String> nonQuit = new ArrayList<>();
217217
String line;
218-
while (true) {
218+
while (in.ready()) {
219219
line = readLine();
220220
if (line == null) {
221221
fail("got EOF before [Bye!]. Extras " + nonQuit);
@@ -297,6 +297,9 @@ public String readLine() throws IOException {
297297
*
298298
* `null` means EOF so we should just pass that back through.
299299
*/
300+
if (in.ready() == false) {
301+
return "";
302+
}
300303
String line = in.readLine();
301304
line = line == null ? null : line.replace("\u001B", "");
302305
logger.info("in : {}", line);
@@ -305,8 +308,8 @@ public String readLine() throws IOException {
305308

306309
private String readUntil(Predicate<String> end) throws IOException {
307310
StringBuilder b = new StringBuilder();
308-
String result;
309-
while (true) {
311+
String result = "";
312+
while (in.ready()) {
310313
int c = in.read();
311314
if (c == -1) {
312315
throw new IOException("got eof before end");

0 commit comments

Comments
 (0)