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 boundary fusion of concatMap and publish operator #6145

Merged
merged 1 commit into from
Aug 8, 2018

Conversation

akarnokd
Copy link
Member

@akarnokd akarnokd commented Aug 7, 2018

This PR fixes the lack of boundary fusion marker in the concatMap and publish operators that can break the thread-confinement expectation when using observeOn upstream and a thread-sensitive operator:

source.observeOn(scheduler)
    .map(/* some thread-sensitive operation */)
    .publish() // or concatMap

By default, these operators may call poll from any of the participating threads which would otherwise dequeue observeOn and execute map on that thread.

The fix adds the necessary flag to both operator's onSubscribe logic. For a temporary workaround, one should use hide() before such operators to make sure fusion doesn't happen.

Fixes: #6144

@akarnokd akarnokd added this to the 2.2 backlog milestone Aug 7, 2018
@codecov
Copy link

codecov bot commented Aug 7, 2018

Codecov Report

Merging #6145 into 2.x will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #6145      +/-   ##
============================================
- Coverage     98.24%   98.23%   -0.02%     
- Complexity     6195     6198       +3     
============================================
  Files           667      667              
  Lines         44857    44857              
  Branches       6213     6213              
============================================
- Hits          44072    44067       -5     
- Misses          242      256      +14     
+ Partials        543      534       -9
Impacted Files Coverage Δ Complexity Δ
...x/internal/operators/flowable/FlowablePublish.java 99.57% <100%> (+2.55%) 11 <0> (ø) ⬇️
...internal/operators/flowable/FlowableConcatMap.java 98.12% <100%> (+0.37%) 6 <0> (ø) ⬇️
.../internal/operators/flowable/FlowableDoOnEach.java 95.34% <0%> (-4.66%) 3% <0%> (ø)
...rnal/operators/flowable/FlowableCombineLatest.java 88.84% <0%> (-3.99%) 8% <0%> (ø)
...ernal/operators/flowable/FlowableFlatMapMaybe.java 89.85% <0%> (-2.9%) 2% <0%> (ø)
...ternal/operators/observable/ObservablePublish.java 96.46% <0%> (-2.66%) 11% <0%> (+1%)
...va/io/reactivex/internal/queue/SpscArrayQueue.java 97.61% <0%> (-2.39%) 22% <0%> (-1%)
...java/io/reactivex/processors/PublishProcessor.java 98.19% <0%> (-1.81%) 42% <0%> (-1%)
...internal/operators/flowable/FlowableSwitchMap.java 95.28% <0%> (-1.42%) 3% <0%> (ø)
...ternal/operators/completable/CompletableMerge.java 97.61% <0%> (-1.2%) 2% <0%> (ø)
... and 25 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 1ad606b...547868f. Read the comment docs.

@akarnokd akarnokd merged commit fd63c49 into ReactiveX:2.x Aug 8, 2018
@akarnokd akarnokd deleted the BoundaryFusionFix branch August 8, 2018 07:42
Copy link
Collaborator

@vanniktech vanniktech left a comment

Choose a reason for hiding this comment

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

👍

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.

Using publish/share/etc leads to upstream operator running on unexpected scheduler
3 participants