Strengthen RecyclerBytesStreamOutputTests#140263
Merged
DaveCTurner merged 1 commit intoelastic:mainfrom Jan 8, 2026
Merged
Conversation
Today `RecyclerBytesStreamOutputTests` only covers the case where the recycler supplies a buffer with zero offset, potentially missing bugs that only arise with slices of a larger pool of buffers. This commit strengthens these tests to verify the behaviour when using a slice of a larger pool, including verification that we never write outside our buffer and that we do not attempt to read from the buffer after it is released.
Collaborator
|
Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination) |
DaveCTurner
commented
Jan 7, 2026
Comment on lines
+797
to
+801
| // This seems kinda trappy: a recycler doesn't guarantee anything about the contents of the buffers it supplies, and in | ||
| // practice it might contain data left there by the previous user. As used today this is all ok, we always overwrite | ||
| // everything eventually in all production usages, but it seems like it might cause problems at some point. | ||
| // TODO should we wipe these contents when extending the stream with a seek like this just to be on the safe side? | ||
| // In the meantime, for this test only, zero out the buffer contents so that it matches expectedBuffer. |
Contributor
Author
There was a problem hiding this comment.
NB this bit, should we address this?
Contributor
There was a problem hiding this comment.
Maybe introduce friends to seek and skip that perform filling, when in doubt? And rename current seek/skip as unsafeSeek saying there might be garbage in between.
mhl-b
approved these changes
Jan 8, 2026
Comment on lines
+797
to
+801
| // This seems kinda trappy: a recycler doesn't guarantee anything about the contents of the buffers it supplies, and in | ||
| // practice it might contain data left there by the previous user. As used today this is all ok, we always overwrite | ||
| // everything eventually in all production usages, but it seems like it might cause problems at some point. | ||
| // TODO should we wipe these contents when extending the stream with a seek like this just to be on the safe side? | ||
| // In the meantime, for this test only, zero out the buffer contents so that it matches expectedBuffer. |
Contributor
There was a problem hiding this comment.
Maybe introduce friends to seek and skip that perform filling, when in doubt? And rename current seek/skip as unsafeSeek saying there might be garbage in between.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Today
RecyclerBytesStreamOutputTestsonly covers the case where therecycler supplies a buffer with zero offset, potentially missing bugs
that only arise with slices of a larger pool of buffers.
This commit strengthens these tests to verify the behaviour when using a
slice of a larger pool, including verification that we never write
outside our buffer and that we do not attempt to read from the buffer
after it is released.