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

Publisher#flatMapConcatIterable may skip emitting items #3108

Merged
merged 1 commit into from
Nov 15, 2024

Commits on Nov 15, 2024

  1. 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.
    Scottmitch committed Nov 15, 2024
    Configuration menu
    Copy the full SHA
    98c817a View commit details
    Browse the repository at this point in the history