-
Notifications
You must be signed in to change notification settings - Fork 2k
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
RntbdBugFix #16204
RntbdBugFix #16204
Conversation
@@ -78,13 +79,16 @@ public static RntbdRequest decode(final ByteBuf in) { | |||
void encode(final ByteBuf out) { | |||
|
|||
final int expectedLength = RntbdRequestFrame.LENGTH + this.headers.computeLength(); | |||
final int start = out.readerIndex(); | |||
final int start = out.writerIndex(); |
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.
could you please explain the scenario which this bug shows itself?
why do we need this?
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.
This change was originally found and fixed in PR https://github.com/Azure/azure-sdk-for-java/pull/14697/files#diff-cdd54a91cbc899239eec06998abac39eL81.
We have not came across any issue today since the writerIndex and readerIndex should be the same. But the writerIndex is the more correct value we should use.
But also feel it may be a risk to depend on the underlying ByteBuf implementation details.
So it is better to change to use the right value.
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 just read the whole code. makes sense to use writerIndex. thanks
...mos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdRequest.java
Outdated
Show resolved
Hide resolved
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
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
update readme (Azure#16204)
This was detected in PR #14697.
WriterIndex and readerIndex should be same when the method is called, but the more correct value to use is writerIndex.