Skip to content
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

2.x: Fix refCount eager disconnect not resetting the connection #6297

Merged
merged 2 commits into from Nov 12, 2018

Conversation

akarnokd
Copy link
Member

@akarnokd akarnokd commented Nov 9, 2018

This PR fixes the case when an observer/subscriber disposes/cancels immediately upon subscribing to a refCount operator before it establishes the connection and ends up with a disposed but non-reset connection, preventing further interactions with the connectable source.

The fix is to detect this case and reset the connection when the connect() method signals the dispose handler.

Both ConnectableFlowable.refCount and ConnectableFlowable.refCount is affected.

Fixes: #6296

@codecov
Copy link

codecov bot commented Nov 9, 2018

Codecov Report

Merging #6297 into 2.x will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #6297      +/-   ##
============================================
+ Coverage     98.24%   98.28%   +0.04%     
- Complexity     6281     6286       +5     
============================================
  Files           672      672              
  Lines         44980    44992      +12     
  Branches       6219     6223       +4     
============================================
+ Hits          44189    44221      +32     
+ Misses          251      241      -10     
+ Partials        540      530      -10
Impacted Files Coverage Δ Complexity Δ
...ernal/operators/observable/ObservableRefCount.java 100% <100%> (ø) 28 <0> (+1) ⬆️
.../internal/operators/flowable/FlowableRefCount.java 100% <100%> (ø) 28 <0> (+1) ⬆️
.../operators/mixed/FlowableConcatMapCompletable.java 97.43% <0%> (-2.57%) 2% <0%> (ø)
...activex/internal/observers/QueueDrainObserver.java 97.43% <0%> (-2.57%) 21% <0%> (-1%)
...ernal/operators/flowable/FlowableFlatMapMaybe.java 91.78% <0%> (-2.42%) 2% <0%> (ø)
...x/internal/operators/flowable/FlowablePublish.java 96.59% <0%> (-2.13%) 11% <0%> (ø)
.../io/reactivex/disposables/CompositeDisposable.java 98.14% <0%> (-1.86%) 39% <0%> (-1%)
...internal/operators/flowable/FlowableSwitchMap.java 95.28% <0%> (-1.42%) 3% <0%> (ø)
...ernal/operators/flowable/FlowableFromIterable.java 95.18% <0%> (-1.07%) 5% <0%> (ø)
...rnal/operators/observable/ObservableSwitchMap.java 93.61% <0%> (-1.07%) 3% <0%> (ø)
... and 26 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 acd5466...f60c09f. Read the comment docs.

.replay(1)
.refCount();

// This line causes the test to fail.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "caused"

.replay(1)
.refCount();

observable.takeUntil(Observable.just(1)).test();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, this line either needs same comment as flowable test, or it should be removed from flowable test

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed from the other place.

@akarnokd akarnokd merged commit 6afd2b8 into ReactiveX:2.x Nov 12, 2018
@akarnokd akarnokd deleted the RefCountReconnectFix1109 branch November 12, 2018 09:26
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.

2.x: refCount doesn't reset its source if one of its subscribers cancels immediately
3 participants