-
Notifications
You must be signed in to change notification settings - Fork 7.6k
2.x: Evaluate Schedule initialization via Callable #4585
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
Changes from 1 commit
0ab5956
5112117
85e14a9
1303f47
e521926
9ccf4ed
38bb3c0
174ce7a
aeafcc7
786090d
c191e31
fff28b2
a273507
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,7 +190,7 @@ public static Function<Scheduler, Scheduler> getSingleSchedulerHandler() { | |
* @throws NullPointerException if the callable parameter or its result are null | ||
*/ | ||
public static Scheduler initComputationScheduler(Callable<Scheduler> defaultScheduler) { | ||
ObjectHelper.requireNonNull(defaultScheduler, "Scheduler Callable cannot be null."); | ||
ObjectHelper.requireNonNull(defaultScheduler, "Scheduler Callable can't be null"); | ||
Function<Scheduler, Scheduler> f = onInitComputationHandler; | ||
if (f == null) { | ||
return call(defaultScheduler); | ||
|
@@ -205,7 +205,7 @@ public static Scheduler initComputationScheduler(Callable<Scheduler> defaultSche | |
* @throws NullPointerException if the callable parameter or its result are null | ||
*/ | ||
public static Scheduler initIoScheduler(Callable<Scheduler> defaultScheduler) { | ||
ObjectHelper.requireNonNull(defaultScheduler, "Scheduler Callable cannot be null."); | ||
ObjectHelper.requireNonNull(defaultScheduler, "Scheduler Callable can't be null"); | ||
Function<Scheduler, Scheduler> f = onInitIoHandler; | ||
if (f == null) { | ||
return call(defaultScheduler); | ||
|
@@ -220,7 +220,7 @@ public static Scheduler initIoScheduler(Callable<Scheduler> defaultScheduler) { | |
* @throws NullPointerException if the callable parameter or its result are null | ||
*/ | ||
public static Scheduler initNewThreadScheduler(Callable<Scheduler> defaultScheduler) { | ||
ObjectHelper.requireNonNull(defaultScheduler, "Scheduler Callable cannot be null."); | ||
ObjectHelper.requireNonNull(defaultScheduler, "Scheduler Callable can't be null"); | ||
Function<Scheduler, Scheduler> f = onInitNewThreadHandler; | ||
if (f == null) { | ||
return call(defaultScheduler); | ||
|
@@ -235,7 +235,7 @@ public static Scheduler initNewThreadScheduler(Callable<Scheduler> defaultSchedu | |
* @throws NullPointerException if the callable parameter or its result are null | ||
*/ | ||
public static Scheduler initSingleScheduler(Callable<Scheduler> defaultScheduler) { | ||
ObjectHelper.requireNonNull(defaultScheduler, "Scheduler Callable cannot be null."); | ||
ObjectHelper.requireNonNull(defaultScheduler, "Scheduler Callable can't be null"); | ||
Function<Scheduler, Scheduler> f = onInitSingleHandler; | ||
if (f == null) { | ||
return call(defaultScheduler); | ||
|
@@ -957,7 +957,7 @@ static <T, R> R apply(Function<T, R> f, T t) { | |
static <T, R> R apply(Function<T, R> f, Callable<T> t) { | ||
try { | ||
T value = t.call(); | ||
ObjectHelper.requireNonNull(t, "Callable result cannot be null."); | ||
ObjectHelper.requireNonNull(t, "Callable result can't be null"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you mean to check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also you could just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, good find. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that would be better. I didn't notice the return value in the signature. |
||
return f.apply(value); | ||
} catch (Throwable ex) { | ||
throw ExceptionHelper.wrapOrThrow(ex); | ||
|
@@ -994,7 +994,7 @@ static <T, U, R> R apply(BiFunction<T, U, R> f, T t, U u) { | |
static <T> T call(Callable<T> t) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. inline this method? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what you mean. I've tried to be consistent with the abstraction of the similar |
||
try { | ||
T result = t.call(); | ||
ObjectHelper.requireNonNull(result, "Callable result cannot be null."); | ||
ObjectHelper.requireNonNull(result, "Callable result can't be null"); | ||
return result; | ||
} catch (Throwable ex) { | ||
throw ExceptionHelper.wrapOrThrow(ex); | ||
|
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.
Should not it throw on a null callable? What's the point of calling with null?
Uh oh!
There was an error while loading. Please reload this page.
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 was done for consistency with the existing expectations in
RxJavaPluginsTest.clearIsPassthrough()
, specifically:Should this be changed to only return null if the
Callable
returns null (and throw if theCallable
itself 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.
Null should not be allowed as a return value from the
Callable
nor from the initFunction
.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 would be a change, because previously the
Scheduler
value forRxJavaPlugins.init*
was allowed to be null, as per -assertNull(RxJavaPlugins.initSingleScheduler(null));
.I will add an additional set of tests for the new behavior (something along the lines of
assemblyHookCrashes
).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.
Done.