Skip to content

Erratic behavior if supplied InputStream does not support mark operations #3

@cjritola

Description

@cjritola

Parsers using expect...() may exhibit erratic behavior if the supplied InputStream does not support mark operations. The Parser class uses mark operations, however when not supported, said mark operations fail silently and the Parser continues without properly rewinding (resetting), resulting in bad input data which causes the Parser to fail to properly parse the stream.

This is most notable in BINFile, where resets are heavily depended upon.

Workaround is to wrap the passed InputStream into a BufferedInputStream, preferrably with a buffer at least large enough as the largest expect...() sequence. In my experience, 4096 bytes is plenty.

An initial fix would be to have the Parser require that the InputStream supports mark operations, verify that mark is supported, or throw an exception on verification fail.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions