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

More nullability annotations #5251

Merged
merged 5 commits into from
Apr 1, 2017
Merged

More nullability annotations #5251

merged 5 commits into from
Apr 1, 2017

Conversation

mibac138
Copy link
Contributor

Added nullability annotations to:

  • Disposables
  • Observers
    and some others

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.

You probably don't want to mess up the imports.

@codecov
Copy link

codecov bot commented Mar 31, 2017

Codecov Report

Merging #5251 into 2.x will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #5251      +/-   ##
============================================
- Coverage     95.97%   95.96%   -0.01%     
- Complexity     5741     5746       +5     
============================================
  Files           628      628              
  Lines         41075    41077       +2     
  Branches       5698     5699       +1     
============================================
- Hits          39420    39418       -2     
- Misses          660      664       +4     
  Partials        995      995
Impacted Files Coverage Δ Complexity Δ
src/main/java/io/reactivex/Single.java 99.32% <ø> (ø) 131 <0> (ø) ⬇️
.../main/java/io/reactivex/exceptions/Exceptions.java 100% <ø> (ø) 6 <0> (ø) ⬇️
src/main/java/io/reactivex/subjects/Subject.java 100% <ø> (ø) 3 <0> (ø) ⬇️
...main/java/io/reactivex/subjects/SingleSubject.java 95.23% <ø> (ø) 38 <0> (ø) ⬇️
...n/java/io/reactivex/parallel/ParallelFlowable.java 100% <ø> (ø) 49 <0> (ø) ⬇️
...activex/observers/ResourceCompletableObserver.java 100% <ø> (ø) 8 <0> (ø) ⬇️
...n/java/io/reactivex/observers/DefaultObserver.java 90% <ø> (ø) 4 <0> (ø) ⬇️
.../io/reactivex/observers/ResourceMaybeObserver.java 100% <ø> (ø) 8 <0> (ø) ⬇️
...o/reactivex/observers/DisposableMaybeObserver.java 100% <ø> (ø) 7 <0> (ø) ⬇️
...ain/java/io/reactivex/disposables/Disposables.java 100% <ø> (ø) 8 <0> (ø) ⬇️
... and 65 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 6c8b0ef...ec17491. Read the comment docs.

Copy link
Member

@akarnokd akarnokd left a comment

Choose a reason for hiding this comment

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

Some of the non-public components don't need annotation.

import io.reactivex.internal.operators.flowable.*;
import io.reactivex.internal.operators.maybe.*;
import io.reactivex.internal.operators.observable.*;
import io.reactivex.internal.functions.Functions;
Copy link
Member

Choose a reason for hiding this comment

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

Please don't unroll star imports.

import io.reactivex.functions.Action;
import io.reactivex.internal.util.ExceptionHelper;

final class ActionDisposable extends ReferenceDisposable<Action> {

private static final long serialVersionUID = -8219729196779211169L;

ActionDisposable(Action value) {
ActionDisposable(@NonNull Action value) {
Copy link
Member

Choose a reason for hiding this comment

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

Non-public components don't really need such annotations.

import java.util.*;

import io.reactivex.exceptions.*;
import io.reactivex.annotations.NonNull;
Copy link
Member

Choose a reason for hiding this comment

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

Please don't unroll star imports.

import io.reactivex.functions.Action;
import io.reactivex.internal.disposables.EmptyDisposable;
import io.reactivex.internal.functions.*;
import io.reactivex.internal.functions.Functions;
Copy link
Member

Choose a reason for hiding this comment

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

Please don't unroll star imports.

@@ -24,7 +26,7 @@

private final boolean allowInterrupt;

FutureDisposable(Future<?> run, boolean allowInterrupt) {
FutureDisposable(@Nullable Future<?> run, boolean allowInterrupt) {
Copy link
Member

Choose a reason for hiding this comment

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

Non-public components don't really need this annotation.

import org.reactivestreams.*;

import io.reactivex.*;
import io.reactivex.Flowable;
Copy link
Member

Choose a reason for hiding this comment

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

Please don't unroll star imports.


import org.reactivestreams.*;

import io.reactivex.annotations.*;
Copy link
Member

Choose a reason for hiding this comment

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

What IDE are you using that reorders imports?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IntelliJ IDEA

@@ -36,7 +35,8 @@

@SuppressWarnings("rawtypes")
static final AsyncSubscription[] TERMINATED = new AsyncSubscription[0];


@NonNull
Copy link
Member

Choose a reason for hiding this comment

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

Non-public, not necessary.

/**
* Holds onto a value along with time information.
*
* @param <T> the value type
*/
public final class Timed<T> {
@Nullable
Copy link
Member

Choose a reason for hiding this comment

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

Not necessary.

@@ -34,7 +37,7 @@
* @param unit the time unit, not null
* @throws NullPointerException if unit is null
*/
public Timed(T value, long time, TimeUnit unit) {
public Timed(@Nullable T value, long time, @NonNull TimeUnit unit) {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this nullable?

Copy link
Member

@akarnokd akarnokd left a comment

Choose a reason for hiding this comment

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

A couple of changes are still needed.

@@ -47,7 +49,7 @@
*
* @throws IllegalArgumentException if <code>exceptions</code> is empty.
*/
public CompositeException(Throwable... exceptions) {
public CompositeException(@Nullable Throwable... exceptions) {
Copy link
Member

Choose a reason for hiding this comment

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

This should be @NonNull.

@@ -59,7 +61,7 @@ public CompositeException(Throwable... exceptions) {
*
* @throws IllegalArgumentException if <code>errors</code> is empty.
*/
public CompositeException(Iterable<? extends Throwable> errors) {
public CompositeException(@Nullable Iterable<? extends Throwable> errors) {
Copy link
Member

Choose a reason for hiding this comment

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

This should be @NonNull.

@@ -32,7 +33,8 @@ private Exceptions() {
* @return because {@code propagate} itself throws an exception or error, this is a sort of phantom return
* value; {@code propagate} does not actually return anything
*/
public static RuntimeException propagate(Throwable t) {
@NonNull
public static RuntimeException propagate(@Nullable Throwable t) {
Copy link
Member

Choose a reason for hiding this comment

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

The argument should be @NonNull.

@@ -61,7 +63,7 @@ public static RuntimeException propagate(Throwable t) {
* the {@code Throwable} to test and perhaps throw
* @see <a href="https://github.com/ReactiveX/RxJava/issues/748#issuecomment-32471495">RxJava: StackOverflowError is swallowed (Issue #748)</a>
*/
public static void throwIfFatal(Throwable t) {
public static void throwIfFatal(@Nullable Throwable t) {
Copy link
Member

Choose a reason for hiding this comment

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

The argument should be @NonNull.

@@ -35,7 +35,7 @@
* @param e
* the {@code Throwable} to signal; if null, a NullPointerException is constructed
*/
public OnErrorNotImplementedException(String message, Throwable e) {
public OnErrorNotImplementedException(String message, @Nullable Throwable e) {
Copy link
Member

Choose a reason for hiding this comment

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

The e argument should be @NonNull.

@@ -31,13 +32,14 @@
*/
public abstract class GroupedObservable<K, T> extends Observable<T> {

@Nullable
Copy link
Member

Choose a reason for hiding this comment

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

No need to annotate this.

@@ -34,7 +35,7 @@
final boolean delayError;

static final int QUEUE_LINK_SIZE = 4;

Copy link
Member

Choose a reason for hiding this comment

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

Whitespace added?

@@ -36,7 +35,7 @@

@SuppressWarnings("rawtypes")
static final AsyncSubscription[] TERMINATED = new AsyncSubscription[0];

Copy link
Member

Choose a reason for hiding this comment

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

Whitespace added?

@@ -44,6 +45,7 @@ public Timed(T value, long time, TimeUnit unit) {
* Returns the contained value.
* @return the contained value
*/
@Nullable
Copy link
Member

Choose a reason for hiding this comment

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

This should be @NonNull.

@@ -34,7 +34,7 @@
*/
@Experimental
public final class SingleSubject<T> extends Single<T> implements SingleObserver<T> {

Copy link
Member

Choose a reason for hiding this comment

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

Whitespace?

@akarnokd akarnokd merged commit fa58d36 into ReactiveX:2.x Apr 1, 2017
@@ -35,7 +35,7 @@
* @param e
* the {@code Throwable} to signal; if null, a NullPointerException is constructed
*/
public OnErrorNotImplementedException(String message, Throwable e) {
public OnErrorNotImplementedException(String message, @NonNull Throwable e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this should be Nullable

@@ -47,7 +47,7 @@ public OnErrorNotImplementedException(String message, Throwable e) {
* @param e
* the {@code Throwable} to signal; if null, a NullPointerException is constructed
*/
public OnErrorNotImplementedException(Throwable e) {
public OnErrorNotImplementedException(@NonNull Throwable e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nullable too.

@@ -47,7 +49,7 @@
*
* @throws IllegalArgumentException if <code>exceptions</code> is empty.
*/
public CompositeException(Throwable... exceptions) {
public CompositeException(@NonNull Throwable... exceptions) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nullable instead? The code handles it explicitly.

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.

4 participants