You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OperatorFinally calls action twice if action throws exception. Exception thrown by action is swallowed #3435
While I was implementing #3434 I've found two problems with OperatorFinally.
I'll call OperatorFinally.action as finallyAction for better readability.
If finallyAction is null — NullPointerException will be swallowed by SafeSubscriber, this can be solved via action != null check in the OperatorFinally (I'll make PR).
If finallyAction throws exception, lift calls onError() and OperatorFinally invokes finallyAction again (this may brake user-defined logic)! And second exception is swallowed by the SafeSubscriber (see problem 1).
I vote for solving both of these problems before 1.0.15/1.1.10.
changed the title [-]OperatorFinally calls action twice if action throws exception and exception is swallowed[/-][+]OperatorFinally calls action twice if action throws exception. Exception thrown by action is swallowed[/+]on Oct 10, 2015
The sequence has already terminated at that point and this operator is there to have side-effects after it. The exception has nowhere to go and there is no guarantee a thrown error reaches its intended target because of a potential async boundary. So it either propagates up to a synchronous caller, gets thrown away by the ExecutorService or gets sent to the error handler.
@akarnokd won't be able to work on this for at least 2 days, feel free to run the tests I posted ^ and see what we can do here or I'll investigate this in the end of the week.
As far as I remember, the biggest problem is that action gets called twice if it throws exception and it may break app's logic in a dramatic manner.
Activity
artem-zinnatullin commentedon Oct 10, 2015
Here are the tests:
artem-zinnatullin commentedon Oct 10, 2015
I'll try to send PRs with fixes ASAP,
nullcheck is easy, but second problem looks tricky.[-]OperatorFinally calls action twice if action throws exception and exception is swallowed[/-][+]OperatorFinally calls action twice if action throws exception. Exception thrown by action is swallowed[/+]akarnokd commentedon Oct 12, 2015
If the action throws, you can't do much but call
RxJavaPlugins.getInstance().getErrorHandler().handleError()for it.artem-zinnatullin commentedon Oct 12, 2015
We can throw it as
Error. Leaving the app in an unknown state is very bad idea, especially in something likefinallyDo().akarnokd commentedon Oct 12, 2015
The sequence has already terminated at that point and this operator is there to have side-effects after it. The exception has nowhere to go and there is no guarantee a thrown error reaches its intended target because of a potential async boundary. So it either propagates up to a synchronous caller, gets thrown away by the
ExecutorServiceor gets sent to the error handler.akarnokd commentedon Feb 9, 2016
Can this be closed?
artem-zinnatullin commentedon Feb 9, 2016
@akarnokd won't be able to work on this for at least 2 days, feel free to run the tests I posted ^ and see what we can do here or I'll investigate this in the end of the week.
As far as I remember, the biggest problem is that
actiongets called twice if it throws exception and it may break app's logic in a dramatic manner.akarnokd commentedon Apr 2, 2016
Fix posted in #3823.
akarnokd commentedon Apr 14, 2016
Closing via #3823