Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-7403

Repeating command with !<number> throws String index out of range and shuts down karaf

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • fuse-7.0
    • fuse-7.0
    • Karaf
    • None
    • % %
    • Hide

      1. echo abc
      2. (lets pretend that this command has id 123 in history)
      3. !123

      Show
      1. echo abc 2. (lets pretend that this command has id 123 in history) 3. !123
    • Fuse 7.0 Sprint 19

    Description

      java.lang.StringIndexOutOfBoundsException: String index out of range: 3
      	at java.lang.String.charAt(String.java:658) ~[?:?]
      	at org.apache.karaf.shell.impl.console.parsing.KarafParser.doParse(KarafParser.java:68) ~[?:?]
      	at org.apache.karaf.shell.impl.console.parsing.KarafParser.parse(KarafParser.java:47) ~[?:?]
      	at org.jline.reader.impl.LineReaderImpl.acceptLine(LineReaderImpl.java:170) ~[140:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000127]
      	at org.jline.reader.impl.LineReaderImpl.access$000(LineReaderImpl.java:67) ~[140:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000127]
      	at org.jline.reader.impl.LineReaderImpl$1.accept(LineReaderImpl.java:98) ~[140:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000127]
      	at org.aesh.readline.Readline$AeshInputProcessor.parse(Readline.java:245) ~[140:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000127]
      	at org.aesh.readline.Readline$AeshInputProcessor.access$100(Readline.java:174) ~[140:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000127]
      	at org.aesh.readline.Readline.readInput(Readline.java:95) ~[140:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000127]
      	at org.aesh.readline.Readline.access$1000(Readline.java:57) ~[140:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000127]
      	at org.aesh.readline.Readline$AeshInputProcessor.lambda$start$1(Readline.java:333) ~[140:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000127]
      	at org.jline.reader.impl.TerminalConnection.openBlocking(TerminalConnection.java:139) [140:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000127]
      	at org.jline.reader.impl.LineReaderImpl.readInput(LineReaderImpl.java:137) [140:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000127]
      	at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:273) [140:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000127]
      	at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.readCommand(ConsoleSessionImpl.java:427) [142:org.apache.karaf.shell.core:4.2.0.fuse-000127]
      	at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSessionImpl.java:385) [142:org.apache.karaf.shell.core:4.2.0.fuse-000127]
      	at org.apache.karaf.shell.impl.console.osgi.DelayedStarted.run(DelayedStarted.java:78) [142:org.apache.karaf.shell.core:4.2.0.fuse-000127]
      	at java.lang.Thread.run(Thread.java:748) [?:?]
      

      The issue is here: https://github.com/apache/karaf/blob/0748a4b4ac993a5c881447121f9ffe127d822a5e/shell/core/src/main/java/org/apache/karaf/shell/impl/console/parsing/KarafParser.java#L68

      I tracked down that "line" is the command you type (!123), but "cursor" is the length of the command you reference from history (echo abc), so you iterate on String of length 4 ("!123") until the index 7 (length of "echo abc")

      Attachments

        Activity

          People

            yfang@redhat.com Freeman(Yue) Fang
            avano@redhat.com Andrej Vano
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: