Skip to content

Using Observable.timeout could cause uncaught exception in RxJava 2.x #4944

Closed
@mbezzubenko

Description

@mbezzubenko

Please have a look at this sample:

public void testSubject() {
    io.reactivex.subjects.PublishSubject<Integer> subject = io.reactivex.subjects.PublishSubject.create();       
    subject
            .timeout(10, TimeUnit.SECONDS, io.reactivex.Observable.error(new RuntimeException()))
            .takeWhile(integer -> integer < 3)
            .toList()
            .subscribe(integers -> System.out.println(integers), throwable -> System.out.println("throwable"));

    subject.onNext(0);
    subject.onNext(1);
    subject.onNext(2);
    subject.onNext(3);

    subject.onError(new RuntimeException());
}

`
It is expected, that after posting value '3' chain emits result [0, 1, 2] and unsubscribes from the subject and subsequent posting of RuntimeException doesn't push it anywhere and doesn't throw it.

But on v2.0.3 it crashes with RuntimeException

The same test with rx.subjects.PublishSubject on v1.2.4 works as expected

If remove timeout from the chain everything works as expected.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions