Skip to content

2.0.0 RC4 Errors get lost with flatMapSingle and Single.fromCallable #4684

Closed
@falcon71

Description

@falcon71

Try the following code:

public static void main(final String[] args) {
        Observable.fromArray(new String[]{"1","a","2"}).flatMapSingle(new Function<String, SingleSource<Integer>>() {
            @Override
            public SingleSource<Integer> apply(final String s) throws NumberFormatException {
                //return Single.just(Integer.valueOf(s)); //This works
                return Single.fromCallable(new Callable<Integer>() {
                    @Override
                    public Integer call() throws NumberFormatException {
                        return Integer.valueOf(s);
                    }
                });
            }
        }).subscribe(new Observer<Integer>() {
            @Override
            public void onSubscribe(final Disposable d) {
                System.out.println("Subscribe");
            }

            @Override
            public void onNext(final Integer value) {
                System.out.println("Value: " + value);
            }

            @Override
            public void onError(final Throwable e) {
                System.out.println("Error: " + e);
            }

            @Override
            public void onComplete() {
                System.out.println("Complete");
            }
        });
    }

The program will only output the Value 1, the NumberFormatException gets lost. If I were to use Single.just, the exception gets printed correctly.

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