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

Clear buffers before returning them to the pool #200

Merged
merged 2 commits into from
Sep 6, 2022

Conversation

vickenty
Copy link
Contributor

@vickenty vickenty commented Aug 4, 2022

After an unsuccessful write, StatsDSender would not clear the buffer before returning it to the pool. This could cause the processor to get the buffer with lim<cap, possibly failing to write to the buffer and incorrectly submitting it to the sender again with pos=0 (which results in a no-op write, because after .flip() buffer would have pos=0,lim=0).

Fixes #198

After an unsuccessful write, StatsDSender would not clear the buffer
before returning it to the pool. This could cause the processor to get
the buffer with lim<cap, possibly failing to write to the buffer and
incorrectly submitting it to the sender again with pos=0 (which
results in a no-op write, because after .flip() buffer would have
pos=0,lim=0).

Fixes #198
@vickenty vickenty requested a review from truthbk August 4, 2022 12:25
Copy link

@remeh remeh left a comment

Choose a reason for hiding this comment

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

LGTM.

@vickenty vickenty merged commit 855f909 into master Sep 6, 2022
@vickenty vickenty deleted the vickenty/buffer-clear branch September 6, 2022 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should ByteBuffer be cleared when exceptions are thrown?
2 participants