Skip to content

Exception thrown from onError() is swallowed when using groupBy/flatMap #2998

Closed
@gdela

Description

@gdela

This issue is related to #969, where it has been said that following code should throw exception:

Observable.error(new Exception())
  .subscribe(new Observer<Object>() {
    public void onCompleted() {
      // noop
    }
    public void onError(Throwable e) {
      throw new IllegalStateException("This should crash the app");
    }
    public void onNext(Object o) {
      // noop
    }
  });

And it does throw exception, but when you add groupBy/flatMap like that:

Observable.error(new Exception())
  .groupBy(o -> o)
  .flatMap(g -> g)
  .subscribe(new Observer<Object>() {
    public void onCompleted() {
      // noop
    }
    public void onError(Throwable e) {
      throw new IllegalStateException("This should crash the app");
    }
    public void onNext(Object o) {
      // noop
    }
  });

Then the exception is silently swallowed. I tried to debug it a little bit, and seems that it could be because OnErrorFailedException is wrapped with CompositeException, so Exceptions.throwIfFatal() doesn't recognize it as fatal.

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