Skip to content

Fatal Exception: java.lang.RuntimeException java.lang.RuntimeException in SafeObserver #650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lexer opened this issue Dec 22, 2013 · 4 comments

Comments

@lexer
Copy link

lexer commented Dec 22, 2013

I get Fatal Exception: java.lang.RuntimeException java.lang.RuntimeException in SafeObserver in cases when both onError and onNext will through exception inside.

observable1
  .subscribe(new Observer<Configs>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        throw new UnknownError("Ooooppsss");
                    }

                    @Override
                    public void onNext(Configs args) {
                        throw new UnknownError("Ooooppsss");
                    }
                }); 

Stack trace:

    java.lang.RuntimeException: Error occurred when trying to propagate error to Observer.onError
            at rx.operators.SafeObserver.onError(SafeObserver.java:109)
            at rx.operators.SafeObserver.onNext(SafeObserver.java:125)
            at rx.Notification.accept(Notification.java:121)
            at rx.operators.OperationObserveOn$ObserveOn$2.call(OperationObserveOn.java:121)
            at rx.operators.OperationObserveOn$ObserveOn$2.call(OperationObserveOn.java:116)
            at rx.Scheduler$3.call(Scheduler.java:163)
            at rx.Scheduler$3.call(Scheduler.java:159)
            at rx.android.concurrency.HandlerThreadScheduler$1.run(HandlerThreadScheduler.java:82)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: rx.util.CompositeException: UnknownError:Ooooppsss, UnknownError:Ooooppsss
            at rx.operators.SafeObserver.onError(SafeObserver.java:109)
            at rx.operators.SafeObserver.onNext(SafeObserver.java:125)
            at rx.Notification.accept(Notification.java:121)
            at rx.operators.OperationObserveOn$ObserveOn$2.call(OperationObserveOn.java:121)
            at rx.operators.OperationObserveOn$ObserveOn$2.call(OperationObserveOn.java:116)
            at rx.Scheduler$3.call(Scheduler.java:163)
            at rx.Scheduler$3.call(Scheduler.java:159)
            at rx.android.concurrency.HandlerThreadScheduler$1.run(HandlerThreadScheduler.java:82)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)
@lexer
Copy link
Author

lexer commented Dec 22, 2013

Issue is very typical for Android. Assume that we do some work with UI in onNext and onError. This work will fail with exception if activity was closed by the time async operation is completed. So we need to ensure that all exceptions in onError and onNext will be suppressed.

@benjchristensen
Copy link
Member

If you want to suppress everything then you need to make sure you don't throw from within onError or an onErrorResumeNext operator. You can swallow the errors if you want, but RxJava won't swallow them automatically.

@lexer
Copy link
Author

lexer commented Dec 24, 2013

@benjchristensen got it! thanks.

@dhavaljivani
Copy link

cant get it how to resolve it??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants