Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BufferUnderflowException and IllegalArgumentException in NonBlockingPumpReader #493

Closed
hyee opened this issue Dec 25, 2019 · 1 comment
Closed
Milestone

Comments

@hyee
Copy link
Contributor

@hyee hyee commented Dec 25, 2019

The issue happens when manually write LineReaderImpl.BRACKETED_PASTE_BEGIN into the reader before reading the input string.

When readBuffer.remaining()<64 then:

java.nio.BufferUnderflowException
        at java.nio.HeapCharBuffer.get(HeapCharBuffer.java:151)
        at java.nio.CharBuffer.get(CharBuffer.java:715)
        at org.jline.utils.NonBlockingPumpReader.readBuffered(NonBlockingPumpReader.java:118)
        at org.jline.keymap.BindingReader.readStringUntil(BindingReader.java:134)
        at org.jline.reader.impl.LineReaderImpl.doReadStringUntil(LineReaderImpl.java:921)
        at org.jline.reader.impl.LineReaderImpl.beginPaste(LineReaderImpl.java:5647)
        at org.jline.reader.impl.LineReaderImpl$1.apply(LineReaderImpl.java:3796)
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:665)
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:493)
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:479)

After fix the above exception, another is thrown:

java.lang.IllegalArgumentException: timeout value is negative
        at java.lang.Object.wait(Native Method)
        at org.jline.utils.NonBlockingPumpReader.wait(NonBlockingPumpReader.java:56)
        at org.jline.utils.NonBlockingPumpReader.read(NonBlockingPumpReader.java:102)
        at org.jline.utils.NonBlockingPumpReader.readBuffered(NonBlockingPumpReader.java:128)
        at org.jline.keymap.BindingReader.readStringUntil(BindingReader.java:134)
        at org.jline.reader.impl.LineReaderImpl.doReadStringUntil(LineReaderImpl.java:921)
        at org.jline.reader.impl.LineReaderImpl.beginPaste(LineReaderImpl.java:5647)
        at org.jline.reader.impl.LineReaderImpl$1.apply(LineReaderImpl.java:3796)
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:665)
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:493)
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:479)
@hyee

This comment has been minimized.

Copy link
Contributor Author

@hyee hyee commented Dec 26, 2019

Besides, readBuffer and writeBuffer could infinitely block each other on the wait function when inputting BRACKETED_PASTE_BEGIN+huge string (1MB)

@gnodet gnodet closed this in c50fe7a Jan 7, 2020
@gnodet gnodet added this to the 3.13.3 milestone Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.