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

Decoder: use of available() call means many InputStream implementations are not supported #43

Open
pjfanning opened this issue May 11, 2024 · 0 comments

Comments

@pjfanning
Copy link

Describe the bug

while (in.available() > 0) {

https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html#available--

If you read the javadoc for available(), you will see that it is only an estimate of the number of bytes that can be read without blocking. It does not relate to the number of remaining bytes in the stream and available=0 cannot be assumed to mean you have reached the end of the stream.

To Reproduce

I found this by using a SequenceInputStream. It can return 0 when you consume one of the underlying streams but before the SequenceInputStream switches over to the next underlying stream.

Expected behavior
Decoder should read any InputStream to completion.

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