2.x: fix cross-boundary invalid fusion with observeOn, flatMap & zip#4984
Merged
akarnokd merged 1 commit intoReactiveX:2.xfrom Jan 12, 2017
Merged
2.x: fix cross-boundary invalid fusion with observeOn, flatMap & zip#4984akarnokd merged 1 commit intoReactiveX:2.xfrom
akarnokd merged 1 commit intoReactiveX:2.xfrom
Conversation
Current coverage is 95.55% (diff: 100%)@@ 2.x #4984 diff @@
==========================================
Files 592 592
Lines 37968 37968
Methods 0 0
Messages 0 0
Branches 5752 5752
==========================================
- Hits 36307 36279 -28
- Misses 701 735 +34
+ Partials 960 954 -6
|
JakeWharton
approved these changes
Jan 12, 2017
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.
When
flatMapandzipfuses its sources, it was possible one of the async source polls on another source which executed boundary-sensitive operators (map,filter) on the wrong thread.For clarity, here is a diagram showing the execution flow of a classical and fused setup:
In the classical flow, everything is push and when flatMap collects the available elements, all side-effects happened inside
map.In the fused flow, there are no queues and the onNext call is an indication to
poll()on the sources insideflatMap(or zip). If the first source triggers onNext, that source is correctly polled andmapexecutes on the right thread. However, when the flatMap continues to collect other available elements, it polls on the other source and executes thatmapstill on the first scheduler, despite that source having its own scheduler specified.The solution is to mark
flatMapandzip's inner consumer as boundary sensitive which prevents the fusion above sincemapis also marked as boundary sensitive.Related: reactor/reactor-core#342