@@ -127,15 +127,6 @@ protected boolean addShutdownHook() {
127
127
exec .start ();
128
128
129
129
try {
130
- // Busy-wait until the input is ready
131
- while (in .ready () == false ) {
132
- try {
133
- Thread .sleep (100 );
134
- } catch (InterruptedException e ) {
135
- Thread .currentThread ().interrupt ();
136
- throw new IllegalStateException (e );
137
- }
138
- }
139
130
// Feed it passwords if needed
140
131
if (security != null ) {
141
132
String passwordPrompt = "[?1h=[?2004hpassword: " ;
@@ -224,7 +215,7 @@ public void close() throws IOException {
224
215
out .flush ();
225
216
List <String > nonQuit = new ArrayList <>();
226
217
String line ;
227
- while (in . ready () ) {
218
+ while (true ) {
228
219
line = readLine ();
229
220
if (line == null ) {
230
221
fail ("got EOF before [Bye!]. Extras " + nonQuit );
@@ -306,8 +297,14 @@ public String readLine() throws IOException {
306
297
*
307
298
* `null` means EOF so we should just pass that back through.
308
299
*/
309
- if (in .ready () == false ) {
310
- return "" ;
300
+ // Busy-wait until the input is ready
301
+ while (in .ready () == false ) {
302
+ try {
303
+ Thread .sleep (100 );
304
+ } catch (InterruptedException e ) {
305
+ Thread .currentThread ().interrupt ();
306
+ throw new IllegalStateException (e );
307
+ }
311
308
}
312
309
String line = in .readLine ();
313
310
line = line == null ? null : line .replace ("\u001B " , "" );
@@ -316,9 +313,18 @@ public String readLine() throws IOException {
316
313
}
317
314
318
315
private String readUntil (Predicate <String > end ) throws IOException {
316
+ // Busy-wait until the input is ready
317
+ while (in .ready () == false ) {
318
+ try {
319
+ Thread .sleep (100 );
320
+ } catch (InterruptedException e ) {
321
+ Thread .currentThread ().interrupt ();
322
+ throw new IllegalStateException (e );
323
+ }
324
+ }
319
325
StringBuilder b = new StringBuilder ();
320
326
String result = "" ;
321
- while (in . ready () ) {
327
+ while (true ) {
322
328
int c = in .read ();
323
329
if (c == -1 ) {
324
330
throw new IOException ("got eof before end" );
0 commit comments