-
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
2.x: Check runnable == null in *Scheduler.schedule*(). #5748
2.x: Check runnable == null in *Scheduler.schedule*(). #5748
Conversation
933fb62
to
9affb70
Compare
@@ -1381,10 +1379,7 @@ public void subscribeActual(MaybeObserver t) { | |||
assertSame(myb, RxJavaPlugins.onAssembly(myb)); | |||
|
|||
|
|||
assertNull(RxJavaPlugins.onSchedule(null)); |
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.
Not sure what was the reason to check null twice here
Codecov Report
@@ Coverage Diff @@
## 2.x #5748 +/- ##
===========================================
- Coverage 96.31% 96.3% -0.02%
+ Complexity 5840 5839 -1
===========================================
Files 634 634
Lines 41650 41651 +1
Branches 5769 5769
===========================================
- Hits 40115 40111 -4
+ Misses 612 610 -2
- Partials 923 930 +7
Continue to review full report at Codecov.
|
@@ -446,6 +446,8 @@ public static Scheduler onNewThreadScheduler(@NonNull Scheduler defaultScheduler | |||
*/ | |||
@NonNull | |||
public static Runnable onSchedule(@NonNull Runnable run) { | |||
ObjectHelper.requireNonNull(run, "runnable is null"); |
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.
Forgot to add explanation to PR why I've added check here and not in Scheduler.schedule*()
methods:
Reason behind that is abstract Scheduler
has 3 overloads, one of them reuses another one + any concrete scheduler can override any of those methods and call other overloads, so as a result I had checks duplicated in some cases.
This RxJavaPlugins
call is done by all schedulers before actual schedule/run of the original Runnable
so it seems to be a good common point that only executed once and guarantees now that Runnable
is not null for both user defined RxJavaPlugins.onSchedule()
function and all RxJava schedulers.
@@ -49,13 +49,17 @@ public Worker createWorker() { | |||
@NonNull | |||
@Override | |||
public Disposable scheduleDirect(@NonNull Runnable run) { | |||
// TODO remove if https://github.com/ReactiveX/RxJava/pull/5747 gets merged. | |||
ObjectHelper.requireNonNull(run, "runnable is null"); |
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.
It's "run is null", but otherwise the run.run()
below would have crashed anyway.
@artem-zinnatullin Could you rebase this PR and reapply your changes? |
Done, sorry for delay. |
To enforce
@NotNull
guarantee for the PR #5734, see https://github.com/ReactiveX/RxJava/pull/5734/files#r153951238