Skip to content

Exception not properly propagated #417

Description

@samuelgruetter

Given

static Func1<Integer, Integer> f = new Func1<Integer, Integer>() {
    public Integer call(Integer arg0) {
        throw new RuntimeException("the error in f");
    }
};

when I run this:

public static void main(String[] args) {
    System.out.println("started");
    System.out.println(Observable.from(1)
        .map(f).toBlockingObservable().single());
    System.out.println("done");
}

I get (as expected) this output:

started
Exception in thread "main" java.lang.RuntimeException: the error in f
    at RxJavaHelloWorld$2.call(RxJavaHelloWorld.java:226)
    at [blah blah...]
    at RxJavaHelloWorld.main(RxJavaHelloWorld.java:240)

However, when I observe it on a different thread:

public static void main(String[] args) {
    System.out.println("started");
    System.out.println(Observable.from(1).observeOn(Schedulers.threadPoolForComputation())
        .map(f).toBlockingObservable().single());
    System.out.println("done");
}

then the output is this:

started

and the application does not terminate.
But I would expect that no matter on what thread I observe, errors are always propagated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions