Skip to content
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

Merged
merged 2 commits into from
Oct 13, 2020
Merged

RntbdBugFix #16204

merged 2 commits into from
Oct 13, 2020

Conversation

xinlian12
Copy link
Member

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.

@@ -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();
Copy link
Contributor

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?

Copy link
Member Author

@xinlian12 xinlian12 Oct 12, 2020

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.

Copy link
Contributor

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

Copy link
Member

@FabianMeiswinkel FabianMeiswinkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@moderakh moderakh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@xinlian12 xinlian12 merged commit edb9229 into Azure:master Oct 13, 2020
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-java that referenced this pull request Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants