-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
3.x: Document Schedulers.from's RejectedExecutionException handling #7150
Conversation
Codecov Report
@@ Coverage Diff @@
## 3.x #7150 +/- ##
============================================
- Coverage 99.55% 99.53% -0.03%
+ Complexity 6709 6706 -3
============================================
Files 745 745
Lines 47327 47327
Branches 6375 6375
============================================
- Hits 47117 47106 -11
- Misses 93 100 +7
- Partials 117 121 +4 Continue to review full report at Codecov.
|
* because such circumstances prevent RxJava from progressing flow-related activities correctly. | ||
* If the {@link Executor#execute(Runnable)} or {@link ExecutorService#submit(Callable)} throws, | ||
* the {@code RejectedExecutionException} is routed to the global error handler via | ||
* {@link RxJavaPlugins#onError(Throwable)}. To avoid shutdown-reladed problems, it is recommended |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a typo?
shutdown-reladed problems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, typos. Would you like to fix them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the PR #7178.
* because such circumstances prevent RxJava from progressing flow-related activities correctly. | ||
* If the {@link Executor#execute(Runnable)} or {@link ExecutorService#submit(Callable)} throws, | ||
* the {@code RejectedExecutionException} is routed to the global error handler via | ||
* {@link RxJavaPlugins#onError(Throwable)}. To avoid shutdown-reladed problems, it is recommended |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a typo?
shutdown-reladed problems
* because such circumstances prevent RxJava from progressing flow-related activities correctly. | ||
* If the {@link Executor#execute(Runnable)} or {@link ExecutorService#submit(Callable)} throws, | ||
* the {@code RejectedExecutionException} is routed to the global error handler via | ||
* {@link RxJavaPlugins#onError(Throwable)}. To avoid shutdown-reladed problems, it is recommended |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a typo?
shutdown-reladed problems
Updates the 3 overloads of
Schedulers.from
to describe (in a concise manner) the cases when theExecutor
would throw aRejectedExecutionException
. Such exceptions can't be reasonably handled from within RxJava.There are typically two cases when such exception would occur:
Operators such as
observeOn
guarantee worker-confinement when callingonNext
,onError
andonComplete
. A failure to schedule would at best bypass this confinement, notifying the downstream on the current thread, at worst cause overlapping execution downstream.The recommended workaround is to cancel all flows using the particular
Scheduler
after which the Executor can be shut down safely.Such temporary rejections are often used in traditional
Executor
usages to drop work or pause the submission of work. In RxJava though, there is often no 1:1 correspondence to signals (onNext
,onError
oronComplete
). Some work may be correlated to severalonNext
s, other work may be due to downstream requests. Dropping any such work may lead to inconsistent flow state or livelocks.The recommended workaround is to express limits on the execution via backpressure (e.g.,
Flowable
s).Resolves #7149