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

Adding NonNull annotations to Observable & Single #6313

Merged
merged 1 commit into from
Dec 19, 2018

Conversation

freakomonk
Copy link
Contributor

@freakomonk freakomonk commented Nov 17, 2018

Adding NonNull annotations in factory methods for improved code compilation

Resolves: #6309

@freakomonk
Copy link
Contributor Author

#6309 @akarnokd Can you pls take a look at this and review ?

@akarnokd akarnokd changed the title Adding NonNull annotation Adding NonNull annotations to Observable & Single Nov 17, 2018
@akarnokd
Copy link
Member

Thanks for Contributing. A few points:

  • You don't have to keep the welcome text of the PR, that's for telling contributors what to do. See the updated text for future reference.
  • Didn't you mean to add @NonNull to the arguments rather than to the return value?

Copy link
Collaborator

@vanniktech vanniktech left a comment

Choose a reason for hiding this comment

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

I like it. Kotlin currently warns about those since it's not capable of inferring whether they can be null or not.

Annotation order should be the same for all usages. This will mix this up.

Can't we use a nonnull by default kind of annotation since 99 percent of the API only uses non null?

@codecov
Copy link

codecov bot commented Nov 17, 2018

Codecov Report

Merging #6313 into 2.x will increase coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #6313      +/-   ##
============================================
+ Coverage     98.23%   98.26%   +0.03%     
- Complexity     6284     6285       +1     
============================================
  Files           672      672              
  Lines         44992    44992              
  Branches       6223     6223              
============================================
+ Hits          44198    44213      +15     
+ Misses          253      244       -9     
+ Partials        541      535       -6
Impacted Files Coverage Δ Complexity Δ
src/main/java/io/reactivex/Flowable.java 100% <ø> (ø) 567 <0> (ø) ⬇️
src/main/java/io/reactivex/Completable.java 100% <ø> (ø) 120 <0> (ø) ⬇️
src/main/java/io/reactivex/Observable.java 100% <ø> (ø) 542 <0> (ø) ⬇️
src/main/java/io/reactivex/Maybe.java 100% <ø> (ø) 172 <0> (ø) ⬇️
src/main/java/io/reactivex/Single.java 100% <ø> (ø) 148 <0> (ø) ⬇️
...tivex/internal/observers/FutureSingleObserver.java 94.33% <0%> (-3.78%) 24% <0%> (-1%)
...rnal/operators/flowable/FlowableFlatMapSingle.java 94.56% <0%> (-1.64%) 2% <0%> (ø)
...ternal/operators/completable/CompletableMerge.java 96.42% <0%> (-1.2%) 2% <0%> (ø)
.../io/reactivex/internal/schedulers/IoScheduler.java 89.36% <0%> (-1.07%) 9% <0%> (ø)
...operators/observable/ObservableMergeWithMaybe.java 99.1% <0%> (-0.9%) 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 6ae765a...c8ad9c4. Read the comment docs.

@akarnokd
Copy link
Member

akarnokd commented Nov 17, 2018

Non-null by default came up in #5341 but not sure what happened. I'd think it was a JSR 305 annotation instead of just a convention thus the IDEs simply wouldn't have supported them.

@freakomonk Did you also want to add these to Maybe, Flowable and Completable static methods?

@freakomonk
Copy link
Contributor Author

freakomonk commented Nov 17, 2018

@vanniktech Can you elaborate nonNull by default ?

@freakomonk
Copy link
Contributor Author

@akarnokd Thanks for the suggestions. Will keep in mind henceforth.

I added the @NonNull annotation to methods with ObjectHelper.requireNonNull check in them. As the input params are being checked for null, I am checking for the return value.

I have updated the Flowable static methods but do not see any Maybe, Completable that do not have already have this annotation.

@vanniktech
Copy link
Collaborator

Non-null by default came up in #5341 but not sure what happened. I'd think it was a JSR 305 annotation instead of just a convention thus the IDEs simply wouldn't have supported them.

This @freakomonk. I'm not sure though which annotations works where and what needs to be enabled/disabled or not. Either we look into this or we just use RxJava's NonNull annotation which does the job.

@freakomonk
Copy link
Contributor Author

@akarnokd Hi David. Is there something else to do to get this PR merged ?

@akarnokd
Copy link
Member

@freakomonk I was waiting for you to add them to the other reactive base classes.

@freakomonk
Copy link
Contributor Author

freakomonk commented Nov 30, 2018

@akarnokd Added annotation to further methods now. Can you pls check ?

@freakomonk
Copy link
Contributor Author

@akarnokd Is this now okay to be merged ? Your review pls

@akarnokd akarnokd merged commit 3481ed1 into ReactiveX:2.x Dec 19, 2018
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.

3 participants