ConsoleReader

367 views
Skip to first unread message

Mike Miller

unread,
Oct 2, 2017, 5:43:15 PM10/2/17
to jline-users
Hello - I am a committer on the Apache Accumulo project and I was looking at upgrading our jline2 dependency to jline3.  I see the ConsoleReader, along with the entire console package was removed in Jline3.  Is there a similar package in jline3?  The closest class I can find is the LineReader.  Accumulo uses the jline2 console package quite extensively throughout our Shell.  https://github.com/apache/accumulo/blob/master/shell/src/main/java/org/apache/accumulo/shell/Shell.java

I couldn't find any code comments or documentation so any tips or advice would be greatly appreciated, thanks!

Guillaume Nodet

unread,
Oct 2, 2017, 6:54:46 PM10/2/17
to jline...@googlegroups.com
Have a look at the following commit
It compiles, though I've no idea if it works, but you should get the idea.

On Mon, Oct 2, 2017 at 11:39 PM, Mike Miller <miller...@gmail.com> wrote:
Hello - I am a committer on the Apache Accumulo project and I was looking at upgrading our jline2 dependency to jline3.  I see the ConsoleReader, along with the entire console package was removed in Jline3.  Is there a similar package in jline3?  The closest class I can find is the LineReader.  Accumulo uses the jline2 console package quite extensively throughout our Shell.  https://github.com/apache/accumulo/blob/master/shell/src/main/java/org/apache/accumulo/shell/Shell.java

I couldn't find any code comments or documentation so any tips or advice would be greatly appreciated, thanks!

--
You received this message because you are subscribed to the Google Groups "jline-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jline-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Miller

unread,
Oct 3, 2017, 1:57:08 PM10/3/17
to jline-users
Thanks Guillaume!  I appreciate the fast and thorough reply.  I will take a look and test the changes.  Will let you know how it goes.

Mike Miller

unread,
Oct 4, 2017, 1:30:18 PM10/4/17
to jline-users
I cherry picked your commit, compiled and started up an Accumulo instance.  I am getting an error when I try to run the Accumulo Shell.  I am not really sure what the LineReader is trying to do, perhaps you would have an idea whats going on?

Stacktrace:
2017-10-04 12:00:43,863 [start.Main] ERROR: Thread 'shell' died.
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.substring(String.java:1967)
    at org.jline.reader.impl.history.DefaultHistory.lambda$load$0(DefaultHistory.java:87)
    at java.util.Iterator.forEachRemaining(Iterator.java:116)
    at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
    at org.jline.reader.impl.history.DefaultHistory.load(DefaultHistory.java:85)
    at org.jline.reader.impl.history.DefaultHistory.attach(DefaultHistory.java:68)
    at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:475)
    at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:390)
    at org.apache.accumulo.shell.Shell.start(Shell.java:657)
    at org.apache.accumulo.shell.Shell.execute(Shell.java:602)
    at org.apache.accumulo.start.Main.lambda$execKeyword$0(Main.java:122)
    at java.lang.Thread.run(Thread.java:748)




On Monday, October 2, 2017 at 5:43:15 PM UTC-4, Mike Miller wrote:

Guillaume Nodet

unread,
Oct 4, 2017, 2:11:51 PM10/4/17
to jline...@googlegroups.com
That's certainly because it's reading an incompatible history file.  The file format has been enhanced to store the command timestamp in addition.
Please raise an issue in jline, as the exception should be caught and logged.
You can easily fix it by deleting your history file.

--

Mike Miller

unread,
Oct 4, 2017, 5:15:24 PM10/4/17
to jline-users
Yup that was it thanks.  I opened up an issue on the Jline3 github issues.  Ok next problem... I am hoping its another easy fix because it has me stumped.  Replacing the use of old constructor for ConsoleReader:
new ConsoleReader(new ByteArrayInputStream(input.getBytes()), baos);
With the following:
Terminal terminal = TerminalBuilder.builder()
.system(false)
.streams(new ByteArrayInputStream(input.getBytes()), baos)
.build();
...
reader = LineReaderBuilder.builder()
.terminal(terminal)
.history(history)
.build();

But nothing gets written to the outputstream in the test. File I am testing is here: https://github.com/milleruntime/accumulo/blob/ACCUMULO-4703/shell/src/test/java/org/apache/accumulo/shell/commands/HistoryCommandTest.java


On Monday, October 2, 2017 at 5:43:15 PM UTC-4, Mike Miller wrote:
Reply all
Reply to author
Forward
0 new messages