-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Fix Azure InputStream#read method #96034
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
Conversation
Pinging @elastic/es-distributed (Team:Distributed) |
Hi @fcofdez, I've created a changelog YAML for you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@@ -714,7 +714,14 @@ private ByteBuf copyBuffer(ByteBuffer buffer) { | |||
@Override | |||
public int read() throws IOException { | |||
byte[] b = new byte[1]; | |||
return read(b, 0, 1); | |||
var bytesRead = read(b, 0, 1); | |||
if (bytesRead > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it return strictly 1 byte?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it should
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest then to make the first condition ==
to surface the issue with exception if more returned (out of paranoia)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM again, but 2 minor comments on the test.
container.writeBlob(blobName, new ByteArrayInputStream(data), data.length, true); | ||
try (var inputStream = container.readBlob(blobName)) { | ||
for (byte blobByte : data) { | ||
assertThat(blobByte, is(equalTo((byte) inputStream.read()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One detail here: can we expand blobByte
instead of narrowing the result of inputStream.read()
? That would validate the & 0xff
works correctly.
assertThat(blobByte, is(equalTo((byte) inputStream.read()))); | |
assertThat((int) blobByte, is(equalTo(inputStream.read()))); |
for (byte blobByte : data) { | ||
assertThat(blobByte, is(equalTo((byte) inputStream.read()))); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add:
assertThat(inputStream.read(), is(equalTo(-1)))
Thanks for the reviews! |
No description provided.