Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,13 @@ void run() throws IOException, InterruptedException {

boolean jlinemissing = false;
// only use jline if it's in the classpath
Class<?> endOfFileExceptionC = null;
Class<?> userInterruptExceptionC = null;
try {
Class<?> readerC = Class.forName("org.jline.reader.LineReader");
Class<?> completerC = Class.forName("org.apache.zookeeper.JLineZNodeCompleter");
endOfFileExceptionC = Class.forName("org.jline.reader.EndOfFileException");
userInterruptExceptionC = Class.forName("org.jline.reader.UserInterruptException");

System.out.println("JLine support is enabled");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about setting jlinemissing to true initially and to false here ?

Copy link
Copy Markdown
Contributor Author

@PDavid PDavid Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, many thanks! 👍
This makes perfect sense and this is so much simpler and easier than I implemented here. 🤦‍♂️ 😄

I tried this out and works nicely. Please check it here: #2369


Expand All @@ -331,8 +335,15 @@ void run() throws IOException, InterruptedException {
| IllegalAccessException
| InstantiationException e
) {
LOG.debug("Unable to start jline", e);
jlinemissing = true;
// Only fall back to terminal without JLine when user not interrupted (Ctrl-C)
// or does not want to exit (Ctrl-D / EOF).
Throwable cause = e.getCause();
boolean isEof = cause != null && cause.getClass().equals(endOfFileExceptionC);
boolean isUserInterrupted = cause != null && cause.getClass().equals(userInterruptExceptionC);
if (!(isEof || isUserInterrupted)) {
LOG.debug("Unable to start jline", e);
jlinemissing = true;
}
}

if (jlinemissing) {
Expand Down