Skip to content

Single not calling doAfterTerminate when used in flatMap #3881

Closed
@solcott

Description

@solcott

I've noticed that when I return a Single from a flatMap and that Single calls doAfterTerminate(Action0) the Action0's call method is never called. This behaviour is not consistent with what happens when you do the same thing with an Observable. I am using 1.1.3

When I run:

Single.just("Test")
    .flatMap(s -> 
        Single.just("Test2")
            .doAfterTerminate(() -> System.out.println("singleFlatMapDoAfterTerminate"))
        )
.doAfterTerminate(() -> System.out.println("singleDoAfterTerminate"))
.subscribe(new TestSubscriber<String>());

I would expect the following to be printed to the console:

singleDoAfterTerminate
singleFlatMapDoAfterTerminate

However only the following is printed to the console

singleDoAfterTerminate

When I do the same with an Observable

Observable.just("Test")
    .flatMap(s -> Observable.just("Test2")
        .doAfterTerminate(() -> System.out.println("observableFlatMapDoAfterTerminate"))
     )
.doAfterTerminate(() -> System.out.println("observableDoAfterTerminate"))
.subscribe(new TestSubscriber<String>());`

I see the following printed to the console:

observableDoAfterTerminate
observableFlatMapDoAfterTerminate

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