Skip to content

Commit ca501d8

Browse files
PDavidanmolnar
authored andcommitted
ZOOKEEPER-5021: Exit from zkCli when interrupt (Ctrl-C) or EOF (Ctrl-D) is pressed
Reviewers: ctubbsii, kezhuw Author: PDavid Closes #2369 from PDavid/ZOOKEEPER-5021-cli-fix-eof-interrupt-2 (cherry picked from commit 6c4fabf) Signed-off-by: Andor Molnar <andor@cloudera.com>
1 parent 2d112ce commit ca501d8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeperMain.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,13 @@ void run() throws IOException, InterruptedException {
308308
if (cl.getCommand() == null) {
309309
System.out.println("Welcome to ZooKeeper!");
310310

311-
boolean jlinemissing = false;
311+
boolean jlinemissing = true;
312312
// only use jline if it's in the classpath
313313
try {
314314
Class<?> readerC = Class.forName("org.jline.reader.LineReader");
315315
Class<?> completerC = Class.forName("org.apache.zookeeper.JLineZNodeCompleter");
316316

317+
jlinemissing = false;
317318
System.out.println("JLine support is enabled");
318319

319320
Object completer = completerC.getConstructor(ZooKeeper.class).newInstance(zk);
@@ -331,8 +332,9 @@ void run() throws IOException, InterruptedException {
331332
| IllegalAccessException
332333
| InstantiationException e
333334
) {
334-
LOG.debug("Unable to start jline", e);
335-
jlinemissing = true;
335+
if (jlinemissing) {
336+
LOG.debug("Unable to start jline", e);
337+
}
336338
}
337339

338340
if (jlinemissing) {

0 commit comments

Comments
 (0)