Chu Cheng Li created HDDS-16721:
-----------------------------------
Summary: StreamBlockInputStream.read() returns a negative value
for bytes 0x80 to 0xFF
Key: HDDS-16721
URL: https://issues.apache.org/jira/browse/HDDS-16721
Project: Apache Ozone
Issue Type: Sub-task
Components: Ozone Client
Reporter: Chu Cheng Li
Assignee: Chu Cheng Li
{{StreamBlockInputStream.read()}} returns the byte it reads sign-extended: it
returns {{readBuffer.getByteBuffer().get()}} as is. A byte of 0x80 or more
comes back as a negative number, and 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.
This affects the streaming read ({{ozone.client.stream.readblock.enable}}) for
callers that read single bytes. {{KeyInputStream}} reads through
{{ByteBuffer}}s, so most reads do not hit it.
The fix is to return {{Byte.toUnsignedInt(...)}}, with a test that reads 0xFF.
Found while splitting https://github.com/apache/ozone/pull/10743, whose Ratis
read stream extends {{StreamBlockInputStream}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]