Skip to content

Commit b908f21

Browse files
authored
Catch StringIndexOutOfBoundException in ConsoleSessionImpl to workaround an issue in JLine (#2242)
1 parent 0f43b2c commit b908f21

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,12 @@ private CharSequence readCommand(AtomicBoolean reading) throws UserInterruptExce
465465
}
466466
} catch (UserInterruptException e) {
467467
command = ""; // Do nothing
468+
} catch (StringIndexOutOfBoundsException e) {
469+
// Workaround for JLine CompletionMatcherImpl bug: Tab on empty line triggers
470+
// substring(0, 1) on "" in defaultMatchers() before EMPTY_WORD_OPTIONS check.
471+
// Re-prompt instead of exiting the shell.
472+
LOGGER.debug("Completion on empty line triggered known JLine edge case", e);
473+
command = "";
468474
} catch (Throwable t) {
469475
ShellUtil.logException(this, t);
470476
} finally {

0 commit comments

Comments
 (0)