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

Concat / MergeWithDelay errors jump the queue when switching threads #3131

Closed
pterhx opened this issue Aug 5, 2015 · 2 comments
Closed

Concat / MergeWithDelay errors jump the queue when switching threads #3131

pterhx opened this issue Aug 5, 2015 · 2 comments

Comments

@pterhx
Copy link

@pterhx pterhx commented Aug 5, 2015

Hi! I'm pretty new to RxJava, so I might be misunderstanding things.

So this works as expected:

    TestSubscriber<String> testSubscriber = new TestSubscriber<>();
    Observable.concat(
            Observable.just("A")
                    .doOnNext(str -> str.length()),
            Observable.error(new NullPointerException())
    ).subscribeOn(Schedulers.io())
            .observeOn(Schedulers.immediate())
            .subscribe(testSubscriber);
    testSubscriber.assertValues("A");
    testSubscriber.assertError(NullPointerException.class);

But when I subscribeOn(Schedulers.io()) and observeOn(AndroidSchedulers.mainThread()) (not this test specifically, but on a device), the error jumps the queue, and I'll never receive "A". Is this supposed to happen?

Note that the doOnNext does get called. It only jumps the queue in the Subscriber. Also, when I put breakpoints to debug, sometimes the error would not jump the queue, so I suspect it's a race condition?

@akarnokd akarnokd added the Question label Aug 11, 2015
@akarnokd
Copy link
Member

@akarnokd akarnokd commented Aug 11, 2015

observeOn when run with a truly async scheduler will make sure the error reaches the downstream even if there are other values queued up. immediate() is not a real scheduler and keeps everything in sequence.

@akarnokd
Copy link
Member

@akarnokd akarnokd commented Sep 3, 2015

There are plans/preview implementation for 2.x to allow specifying error delay behavior on more kinds of operators, not just merge/flatMap. I don't really see this feature being added to 1.x in a short timeframe due to API concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.