Skip to content

Completable.concat(Obsevable<Completable>..) unsubscribes from child completables not in time #4848

@sobersanta

Description

@sobersanta

Hi

Loving playing with new Completables and Singles! But seems that we have found a bug running them on our production server,
and after fighting for 30 minutes with and not being able to find the exact cause, we have written a simple test which is attached here and proves the issue.

By executing it you can see that old good Observables.concat works perfectly, but it's younger brother Completable.concat does not.

We observe that it ubsubscribes somewhere in the chain from child completables, and by executing the test several times you can see that sequence is uneven and order of processing/ubsubscribed messages changes from time to time.

The file attached:

Test.zip

I believe it's not how it should work - I expect that all child completables complete before they are unsubscribed from by the upstream operator.

The sample code that does not work as I expect:

`

    System.out.println("Testing Completable.concat");
    System.out.println();
    Completable.concat(
            Observable.range(1, 5).map(integer -> Completable.fromAction(() -> {
                try {
                    System.out.println("Processing " + integer + "...");
                    Thread.sleep(100);
                    System.out.println("Processing " + integer + " finished");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            })
                    .doOnUnsubscribe(() -> System.out.println("Unsubscribed from " + integer))
                    .subscribeOn(Schedulers.io()).observeOn(Schedulers.computation()))
                    .doOnUnsubscribe(() -> System.out.println("Unsubscribed from parent observable"))
    ).subscribe(() -> {
                System.out.println("Finished Completable.concat");
            }, Throwable::printStackTrace
    );

`

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