peterxcli opened a new pull request, #11411: URL: https://github.com/apache/ozone/pull/11411
## What changes were proposed in this pull request? `StreamBlockInputStream.read()` returns the byte it reads sign-extended. A byte of 0x80 or more comes back as a negative number, and the byte 0xFF comes back as -1, which callers take as the end of the stream. `InputStream.read()` must return 0 to 255, or -1 at the end of the stream. With this change, `read()` returns `Byte.toUnsignedInt(...)` of the byte, as `ExtendedInputStream.read()` already does. Normal key reads are not affected today: `KeyInputStream` reaches the block stream through `ExtendedInputStream.read()`, which reads into a buffer. The bug shows up for code that calls `read()` on the block stream itself, such as the Ratis read stream being added under HDDS-9904, which extends `StreamBlockInputStream`. ## What is the link to the Apache JIRA https://issues.apache.org/jira/browse/HDDS-16721 ## How was this patch tested? New unit test `TestStreamBlockInputStream#testReadReturnsUnsignedByte`: it reads a block holding the bytes 0x80 and 0xFF one byte at a time, and checks that it gets 128, then 255, then the end of the stream. Without the fix, it fails with `expected: <128> but was: <-128>`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
