This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/main by this push:
     new 8f1554d400 Catch StringIndexOutOfBoundException in ConsoleSessionImpl 
to workaround an issue in JLine (#2237)
8f1554d400 is described below

commit 8f1554d400a9df2de9f5990972e4ff1d3943601d
Author: JB Onofré <[email protected]>
AuthorDate: Mon Jan 26 09:06:58 2026 +0100

    Catch StringIndexOutOfBoundException in ConsoleSessionImpl to workaround an 
issue in JLine (#2237)
---
 .../org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java     | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git 
a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
 
b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
index d61509f3cd..a14ee42177 100644
--- 
a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
+++ 
b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
@@ -465,6 +465,12 @@ public class ConsoleSessionImpl implements Session {
             }
         } catch (UserInterruptException e) {
             command = ""; // Do nothing
+        } catch (StringIndexOutOfBoundsException e) {
+            // Workaround for JLine CompletionMatcherImpl bug: Tab on empty 
line triggers
+            // substring(0, 1) on "" in defaultMatchers() before 
EMPTY_WORD_OPTIONS check.
+            // Re-prompt instead of exiting the shell.
+            LOGGER.debug("Completion on empty line triggered known JLine edge 
case", e);
+            command = "";
         } catch (Throwable t) {
             ShellUtil.logException(this, t);
         } finally {

Reply via email to