JLine blocked when reading after end-of-file (original) (raw)

While investigating an Apache Hive issue, I noticed that executing a script file blocks when using a JLine 3.x version >= 3.30.8. I managed to reproduce it with the latest jline-3.x branch (b832cde) with a unit test:

In org.jline.reader.impl.LineReaderTest#terminalLineInfiniteLoop, add the check

assertThrows(EndOfFileException.class, lineReader::readLine);

at the end of the test method.

It would also be nice to add explicit tests for TerminalProvider[exec] and TerminalProvider[jni]. I've implemented such tests in my fork. I had to add the JVM arg --enable-native-access=ALL-UNNAMED so that the provider is actually loaded.

I've debugged it a bit and found the following: