Skip to content

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

Closed
@RoryKelly

Description

@RoryKelly

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();
    }

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