Skip to content

2.x: fix replay().refCount() leaking items between connections #5182

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

Merged
merged 1 commit into from
Mar 14, 2017

Conversation

akarnokd
Copy link
Member

This PR updates Observable.replay() and Flowable.replay() for 2.x to not leak items between reconnections when run with .refCount(). The replay() operator is designed to hold onto the buffer even after its completion so late subscribers can still receive the cached data. Only a new connect() clears this data which may or may not happen. Since refCount ensures that there won't be any latecommers to an already completed connection (because it also drops its current subscribers on termination or when reaching zero), the replay() can be reset to an empty state.

Related: #5172, #5181.

@akarnokd akarnokd added this to the 2.0 backlog milestone Mar 13, 2017
@codecov
Copy link

codecov bot commented Mar 13, 2017

Codecov Report

Merging #5182 into 2.x will decrease coverage by 0.03%.
The diff coverage is 100%.

@@             Coverage Diff             @@
##                2.x   #5182      +/-   ##
===========================================
- Coverage     96.04%     96%   -0.04%     
- Complexity     5655    5665      +10     
===========================================
  Files           621     621              
  Lines         40320   40336      +16     
  Branches       5610    5616       +6     
===========================================
+ Hits          38725   38726       +1     
- Misses          630     640      +10     
- Partials        965     970       +5
Impacted Files Coverage Δ Complexity Δ
.../internal/operators/flowable/FlowableRefCount.java 98.71% <100%> (+0.06%) 7 <0> (ø)
...ernal/operators/observable/ObservableRefCount.java 98.68% <100%> (+0.07%) 7 <0> (ø)
...nternal/operators/observable/ObservableReplay.java 97.77% <100%> (-0.26%) 22 <4> (+3)
...ex/internal/operators/flowable/FlowableReplay.java 90.69% <100%> (+0.07%) 21 <4> (+4)
...al/operators/observable/ObservableSampleTimed.java 88.33% <0%> (-8.34%) 3% <0%> (ø)
...in/java/io/reactivex/subjects/BehaviorSubject.java 84.97% <0%> (-4.67%) 56% <0%> (+1%)
...a/io/reactivex/internal/util/QueueDrainHelper.java 60.28% <0%> (-4.26%) 32% <0%> (-3%)
...rnal/operators/completable/CompletableTimeout.java 94% <0%> (-4%) 2% <0%> (ø)
.../operators/observable/ObservableFlatMapSingle.java 92.53% <0%> (-3.74%) 2% <0%> (ø)
...reactivex/internal/operators/single/SingleAmb.java 96.36% <0%> (-3.64%) 9% <0%> (-1%)
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 88c60b9...c2f2435. Read the comment docs.

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