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
* Fix BoundedInputStream not counting null-bytes
Motivation:
The `InputStream.read()` method returns the byte value as an `int` in the range 0 to 255.
The `BoundedInputStream` has a bug in counting the number of bytes read, where valid 0-bytes were not counted toward the limit.
Modification:
The `BoundedInputStream` is changed to only consider -1 as EOF, which is exactly as documented on `InputStream`.
The `BoundedInputStream` is also changed to truncate and allow reads up to the limit, and then only trip the exception when it is at the limit and reads beyond.
The `BoundedInputStreamTest` has also been made repeating, because it was already occasionally finding this problem.
The test now passes consistently with the fixes.
Result:
The `BoundedInputStream` now counts all byte values toward the limit.
* Add deterministic test
* Refine deterministic test
---------
Co-authored-by: Chris Vest <[email protected]>
0 commit comments