Skip to content

Fix ByteBufferBsonOutput buffer caching logic. #1683

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Apr 18, 2025

Conversation

vbabanin
Copy link
Member

@vbabanin vbabanin commented Apr 17, 2025

Summary

PR #1651 missed changes introduced in PR #1675, leading to incorrect buffer handling in ByteBufferBsonOutput.
This PR merges both changes to resolve the issue.

Changes

  • Replaced getNextByteBuffer with getCurrentByteBuffer in writeOnBuffers to correct buffer state management, because getNextByteBuffer failed to update currentByteBuffer, causing encoding errors.

JAVA-5816

Replaced getNextByteBuffer with getCurrentByteBuffer in writeOnBuffers to correct
buffer state management. getNextByteBuffer failed to update currentByteBuffer,
causing encoding errors.

JAVA-5816
@vbabanin vbabanin requested review from a team and stIncMale and removed request for a team April 17, 2025 23:42
@@ -176,6 +175,7 @@ private ByteBuf getCurrentByteBuffer() {
if (currentByteBuffer == null) {
currentByteBuffer = getByteBufferAtIndex(curBufferIndex);
}

Copy link
Member

Choose a reason for hiding this comment

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

[optional]

Was this change intentional or accidental? I ma pointing it out just in case it was an accident. If not, feel free to merge.

Copy link
Member Author

@vbabanin vbabanin Apr 18, 2025

Choose a reason for hiding this comment

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

The change was intentional - i thought visually separating the branches (after the recent changes in #1675) might help make the logic a bit more apparent. Thank you for flagging it!

@vbabanin vbabanin merged commit 99a6f32 into mongodb:main Apr 18, 2025
46 of 54 checks passed
@vbabanin vbabanin self-assigned this Apr 18, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants