-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publisher#flatMapConcatIterable may skip emitting items
Motivation: Publisher#flatMapConcatIterable may not emit some items due to race conditions and visibility issues. The iterator state is written to outside the scope of holding the lock. After a drain loop completes we may request 1 more iterator. However it is possible the thread emitting holds the lock while another thread invokes onNext(t). The emitting thread may not see the iterator, and instead see `EmptyIterator.instance()` and cause it to request 1 more item, but then the not-visible iterator contents won't be emitted. Modifications: - Make FlatMapIterableSubscriber iterator state volatile and atomically update it. There is only ever 1 valid iterator because only 1 outstanding demand is issued only after the current iterator `!hasNext()`. The iterator state is re-read on each drain loop, and the terminal condition must atomically set to EmptyIterator.
- Loading branch information
1 parent
af01383
commit 831bf48
Showing
2 changed files
with
47 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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