Skip to content

ByteArrayInputStream will throw unexcepted EOFException #116

Open
@LoveHeat

Description

@LoveHeat

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());
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions