Skip to content

Drain applies mappers without scheduling. #5990

@AlecKazakova

Description

@AlecKazakova

Here is the test case I've created

val testThread = Thread.currentThread();

rx.Observable.fromCallable { 10 }
        .toV2()
        .switchMap { original -> BehaviorSubject.createDefault(2)
            .observeOn(Schedulers.io())
            .map { multiplier ->
              if (Thread.currentThread() == testThread) throw AssertionError()
              original * multiplier
            }
        }
        .subscribe { throw IllegalStateException("nice") }

Thread.sleep(1000)

This hits the assertion error as SwitchMapObserver polls the inner query inside its drain method, running the poll method on MapObserver which ends up running on the thread the switchmap was subscribed to on (i think?).

I dont think the interop part is necessary to reproduce this bug, but was the consistent way I was able to get the drain method to poll the inner query as fromCallable emits a completion after the relay has emitted but before the mapper has received the event.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions