jline / jline3

JLine is a Java library for handling console input.
Other
1.46k stars 215 forks source link

Infinite loop when reading empty string #8

Closed spacecowboy closed 8 years ago

spacecowboy commented 8 years ago

Trying to upgrade from jline2 and ran into this. Here's a test to reproduce:

    @Test
    public void emptyStringGivesEOF() throws Exception {
        String inputString = "";
        InputStream inputStream = new ByteArrayInputStream(inputString.getBytes());

        LineReaderBuilder builder =
                LineReaderBuilder.builder()
                                 .terminal(TerminalBuilder.builder()
                                                          .streams(inputStream, System.out)
                                                          .build());

        LineReader reader = builder.build();

        // this gets trapped in an infinite loop
        assertNull(reader.readLine());
    }
gnodet commented 8 years ago

I'll fix the problem, but you should expect an EndOfFileException to be thrown instead of a null return.