You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
cjritola
changed the title
Erratic behavior is supplied InputStream does not support mark operations
Erratic behavior if supplied InputStream does not support mark operations
Feb 12, 2024
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.
The text was updated successfully, but these errors were encountered: