Skip to content
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: Fix & prevent null checks on primitives #6014

Merged
merged 1 commit into from
May 23, 2018

Conversation

akarnokd
Copy link
Member

@akarnokd akarnokd commented May 23, 2018

This PR removes the accidental null checks on primitives in two Observable methods and adds a trap method to ObjectHelper to both highlight and fail the tests in case the null checks are still attempted. The method is marked as deprecated so it will also show up in (Eclipse's) problems window.

Replaces #6012
Resolves #6013

@codecov
Copy link

codecov bot commented May 23, 2018

Codecov Report

Merging #6014 into 2.x will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##                2.x   #6014      +/-   ##
===========================================
+ Coverage     98.28%   98.3%   +0.02%     
- Complexity     6161    6162       +1     
===========================================
  Files           659     659              
  Lines         44522   44519       -3     
  Branches       6201    6201              
===========================================
+ Hits          43757   43763       +6     
+ Misses          233     227       -6     
+ Partials        532     529       -3
Impacted Files Coverage Δ Complexity Δ
src/main/java/io/reactivex/Observable.java 100% <ø> (ø) 539 <0> (ø) ⬇️
.../io/reactivex/internal/functions/ObjectHelper.java 100% <100%> (ø) 22 <1> (+1) ⬆️
.../io/reactivex/internal/schedulers/IoScheduler.java 89.24% <0%> (-3.23%) 9% <0%> (ø)
...tivex/internal/schedulers/TrampolineScheduler.java 96.1% <0%> (-2.6%) 6% <0%> (ø)
.../internal/disposables/ListCompositeDisposable.java 98% <0%> (-2%) 34% <0%> (-1%)
...nternal/operators/observable/ObservableWindow.java 98% <0%> (-2%) 3% <0%> (ø)
...ernal/operators/flowable/FlowableFlatMapMaybe.java 94.68% <0%> (-1.94%) 2% <0%> (ø)
.../io/reactivex/disposables/CompositeDisposable.java 98.14% <0%> (-1.86%) 39% <0%> (-1%)
...rnal/subscriptions/DeferredScalarSubscription.java 98.46% <0%> (-1.54%) 28% <0%> (-1%)
...l/operators/observable/ObservableFlatMapMaybe.java 89.54% <0%> (-1.31%) 2% <0%> (ø)
... and 20 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5f1ce20...3689fe5. Read the comment docs.

@akarnokd akarnokd merged commit 4af78a7 into ReactiveX:2.x May 23, 2018
@akarnokd akarnokd deleted the AccidentalAutoboxing branch May 23, 2018 07:23
*/
@Deprecated
public static long requireNonNull(long value, String message) {
throw new InternalError("Null check on a primitive: " + message);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not the best choice of error type, InternalError indicates JVM error, combined with "Null check on a primitive" message might mislead the developer into thinking that something is wrong with bytecode/VM hehe

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially if they run a value types enabled vm ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants