Skip to content
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

2.x: error handling - exception swallowed after explicit .dispose(). #6025

Closed
yunikkk opened this issue May 28, 2018 · 3 comments
Closed

2.x: error handling - exception swallowed after explicit .dispose(). #6025

yunikkk opened this issue May 28, 2018 · 3 comments

Comments

@yunikkk
Copy link

yunikkk commented May 28, 2018

Library verision : 2.1.7

The following code will silently swallow thrown exception without signalling to RxPlugins.

        val subject = PublishSubject.create<Unit>()

        var disposable: Disposable? = null
        disposable = subject.subscribe(
                {
                    disposable?.dispose()
                    throw Exception("test")
                }
        )

        subject.onNext(Unit)

The same applies to BehaviourSubject, *Processor, but not SingleSubject or Observable.just (.range etc. ). Though sections about error handling are almost equal in PublishSubject and SingleSubject.

The reason seems to be located in LambdaObserver, which doesn't signal onError if is disposed already.

Is it expected behaviour?

@akarnokd
Copy link
Member

Indeed it does not. The tradeoff here is that your code explicitly indicated it doesn't want to handle further events yet there would be no opportunity to have onError not signal to the global error handler.

I'm open for discussion.

@yunikkk
Copy link
Author

yunikkk commented May 28, 2018

As for me the exception should still be thrown somewhere, as the code is still executed and doing something wrong. So if .dispose() is requested and onError can not be called - it seems to me that this corresponds 2.x error handling philosophy when the error falls directly into global handler.

@akarnokd akarnokd added this to the 2.2 milestone May 30, 2018
@akarnokd akarnokd added the Bug label May 30, 2018
@akarnokd
Copy link
Member

Well, other implementations do route to the global error handler so for the sake of consistency, this should be fixed. PR welcome.

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

No branches or pull requests

2 participants