4.x: Release replay buffers from cancelled consumers - #8317
Merged
akarnokd merged 1 commit intoOct 5, 2026
Merged
Conversation
akarnokd
approved these changes
Oct 5, 2026
🐷 TruffleHog + Entropy Beauty ScanAverage entropy of changed code: 4.331 bits/char Changed files entropy: ✅ No secrets or suspicious high-entropy strings found. Mid-4 beauty heuristic in action — powered by our entropy chats! 😊 |
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.
Holding a cancelled raw replay
DisposableorSubscriptionkept the replay owner and its cached values reachable. Release that parent reference inObservableReplay,FlowableReplay,ReplaySubject, andReplayProcessor, and coordinate cursor cleanup with an active replay so cancellation cannot leave a stale linked node behind. Keep the request-management notification that may unblock other Flowable subscribers, and tolerate a concurrent request after the parent has been released.The regression tests use public APIs, discard received values, and retain the original cancelled handle while checking the cached value through a weak reference. They cover unbounded, size-bounded, and time-and-size-bounded buffers for all four components, repeated cancellation, requests after cancellation, and request/cancel races.
Related #7912. This addresses cancellation retention; it does not resolve every remaining cache/replay GC item in that issue.
Validation on JDK 26 / Gradle 9.8:
The source SHA and raw file hashes are checked before and after execution. Only the four production classes and the regression test are in the PR; the external test-fork configuration and evidence workflow are outside its diff.
AI disclosure: I used Codex to investigate the retention path and develop the implementation and regression tests. The reasoning was that a custom consumer can legitimately retain its cancelled handle, but that handle no longer needs the independent replay owner or buffer. Review feedback will be followed up here.