Skip to content

ByteArrayInputStream will throw unexcepted EOFException #116

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

Open
LoveHeat opened this issue Aug 2, 2023 · 0 comments
Open

ByteArrayInputStream will throw unexcepted EOFException #116

LoveHeat opened this issue Aug 2, 2023 · 0 comments

Comments

@LoveHeat
Copy link

LoveHeat commented Aug 2, 2023

The way we use ByteArrayInputStream is:
call enterBlock() ---> call mark() ---> call readInteger() ---> call reset()
after reset() is called, we will call read again, but it will throw EOFException, after review code, i found the reason maybe that we don't reset blockLength after reset() is called, the test code can simulate the bug:

@Test
public void testMarkAndReset() throws Exception {
    ByteArrayInputStream in = new ByteArrayInputStream(new byte[] {1, 2, 3, 4});
    in.enterBlock(4);
    in.mark(4);
    in.readInteger(4);
    in.reset();

    assertEquals(1, in.read());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant