Skip to content

4.x: Fix consumer retention in cache() upon subscribe-cancel race - #8283

Merged
akarnokd merged 2 commits into
ReactiveX:4.xfrom
akarnokd:4xCacheSelfDisposeLeakFix
Aug 11, 2026
Merged

4.x: Fix consumer retention in cache() upon subscribe-cancel race#8283
akarnokd merged 2 commits into
ReactiveX:4.xfrom
akarnokd:4xCacheSelfDisposeLeakFix

Conversation

@akarnokd

Copy link
Copy Markdown
Member

When the incoming Subscriber or Observer cancels while in their respective onSubscribe or race it afterwards, the operator could retain it in its consumer tracking array indefinitely, depending on the cached source.

The fix is, like many other place is to after add, check if the consumer cancelled and then manually remove them for sure.

In addition, apparently the test cancelledUpFrontConnectAnyway was missing from ObservableCacheTest which is important because the cache operator is expected to connect, even with dead consumers.

Privately reported as an ??? exploit ???

@August829

RxJava-09: ObservableCache/FlowableCache Register Consumers Before Checking Disposed State — Self-Disposing Subscribers Permanently Retained

🛑 Do not report bugs as security exploits. 🛑

@akarnokd akarnokd added this to the 4.0 milestone Aug 11, 2026
@github-actions

Copy link
Copy Markdown

🐷 TruffleHog + Entropy Beauty Scan

Average entropy of changed code: 4.46 bits/char
Verdict: ✅ Mid-4 beauty detected (thoughtful human code!)

Changed files entropy:

src/main/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableCache.java: 4.229
src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableCache.java: 4.191
src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableCacheTest.java: 4.696
src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableCacheTest.java: 4.724

✅ No secrets or suspicious high-entropy strings found.

Mid-4 beauty heuristic in action — powered by our entropy chats! 😊

@github-actions

Copy link
Copy Markdown

🐷 TruffleHog + Entropy Beauty Scan

Average entropy of changed code: 4.492 bits/char
Verdict: ✅ Mid-4 beauty detected (thoughtful human code!)

Changed files entropy:

src/main/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableCache.java: 4.229
src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableCache.java: 4.191
src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableCacheTest.java: 4.696
src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableCacheTest.java: 4.724
src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableFlatMapTest.java: 4.622

✅ No secrets or suspicious high-entropy strings found.

Mid-4 beauty heuristic in action — powered by our entropy chats! 😊

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.61%. Comparing base (dde738d) to head (4351a47).
⚠️ Report is 1 commits behind head on 4.x.

Additional details and impacted files
@@             Coverage Diff              @@
##                4.x    #8283      +/-   ##
============================================
- Coverage     98.65%   98.61%   -0.04%     
- Complexity     7147     7148       +1     
============================================
  Files           824      824              
  Lines         50784    50789       +5     
  Branches       6907     6910       +3     
============================================
- Hits          50101    50087      -14     
- Misses          473      481       +8     
- Partials        210      221      +11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@akarnokd
akarnokd merged commit 61b02bb into ReactiveX:4.x Aug 11, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant