Correctly flag BufferedPersistentStreamSegment#isClosed - #511
Merged
smcvb merged 1 commit intoAug 25, 2026
Merged
Conversation
We should correctly flag a BufferedPersistentStreamSegment as closed. Firstly, we should rely on the FlowControlledBuffer#isClosed() instead of having a custom implementation. Furthermore, we should use the closed AtomicBoolean for both close() and onCompleted() in a CaS false-true style. Correcting this functionality allows consumers to base themselves on isClosed per JavaDoc description, ensuring a user does not accidentally skips queued events.
|
m1l4n54v1c
approved these changes
Aug 24, 2026
MGathier
approved these changes
Aug 25, 2026
smcvb
deleted the
bug/persistent-stream-lets-consumers-skip-events-on-termination
branch
August 25, 2026 07:15
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.



This PR corrects the
isClosedbehavior of theBufferedPersistentStreamSegment.To that end, we firstly should rely on the
FlowControlledBuffer#isClosed()instead of having a custom implementation in theBufferedPersistentStreamSegment.Remove this ensure the
BufferedPersistentStreamSegmentdoes not eagerly report it's closed even though there are still some events buffered in it, as that violates the described contract of theResultStream.Furthermore, we should use the closed
AtomicBooleanfor bothBufferedPersistentStreamSegment#closeandBufferedPersistentStreamSegment#onCompletedin a compare-and-set (false to true) check.This ensure we only enqueue the terminal message of the
BufferedPersistentStreamSegmentonce, guarded by the aforementionedAtomicBoolean closed.Fixing the above allows consumers (e.g., Axon Framework) to base themselves on
isClosedper JavaDoc description, ensuring a user does not accidentally skips buffered events.