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

toSingle() leaks subscriber if followed by flatmap. #3940

Closed
RoryKelly opened this issue May 13, 2016 · 1 comment
Closed

toSingle() leaks subscriber if followed by flatmap. #3940

RoryKelly opened this issue May 13, 2016 · 1 comment
Labels

Comments

@RoryKelly
Copy link

Not sure this is a correct test, let me know if I can provide any extra information.

    private Subscriber<? super Object> subscriber;

    @Test public void thisTestPasses() throws Exception {

        final Subscription subscribe = Observable.create(subscriber -> {
            this.subscriber = subscriber;
        }).subscribeOn(Schedulers.io()).flatMap(o -> Observable.just("")).toSingle().subscribe();

        subscribe.unsubscribe();

        assertThat(subscriber.isUnsubscribed()).isTrue();
    }

    @Test public void thisTestFails() throws Exception {

        final Subscription subscribe = Observable.create(subscriber -> {
            this.subscriber = subscriber;
        }).subscribeOn(Schedulers.io()).toSingle().flatMap(o -> Single.just("")).subscribe();

        subscribe.unsubscribe();

        assertThat(subscriber.isUnsubscribed()).isTrue();
    }
@akarnokd
Copy link
Member

Thanks for reporting. Indeed, this is a bug in Single.flatMap. Fix PR in #3941 .

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

No branches or pull requests

2 participants