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
Fix a race in some tests for JavaRX integration (#1801)
An extremely rare race could happen in any of the tests in
`LeakedExceptionTest` in the following case:
* `withExceptionHandler` runs the block passed to it;
* In one of the last iterations of `repeat`, `select` in `combine`
happens on both flows at the same time, that is, the block that
was passed to `rx[Something]` runs in two threads
simultaneously;
* One of these two threads (thread A) runs anomalously slow;
* The other thread successfully throws an exception;
* This exception is propagated to `catch`, so `collect` is
finished;
* `repeat` is exited, the block passed to `withExceptionHandler` is
done executing;
* `withExceptionHandler` sets back the usual exception handler,
which fails when an exception in JavaRX happens (see
https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling);
* Thread A wakes up and throws an exception. This time, it is
passed not to `handler`, which is made specifically to deal with
this, but to the default handler.
As a fix, now a special coroutine context passed to `rx[Something]`
ensures that the spawned executions are run in a thread pool that
blocks until all the tasks are done.
0 commit comments