-
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
More nullability annotations #5251
Conversation
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.
You probably don't want to mess up the imports.
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
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.
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; |
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.
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) { |
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.
Non-public components don't really need such annotations.
import java.util.*; | ||
|
||
import io.reactivex.exceptions.*; | ||
import io.reactivex.annotations.NonNull; |
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.
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; |
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.
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) { |
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.
Non-public components don't really need this annotation.
import org.reactivestreams.*; | ||
|
||
import io.reactivex.*; | ||
import io.reactivex.Flowable; |
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.
Please don't unroll star imports.
|
||
import org.reactivestreams.*; | ||
|
||
import io.reactivex.annotations.*; |
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.
What IDE are you using that reorders imports?
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.
IntelliJ IDEA
@@ -36,7 +35,8 @@ | |||
|
|||
@SuppressWarnings("rawtypes") | |||
static final AsyncSubscription[] TERMINATED = new AsyncSubscription[0]; | |||
|
|||
|
|||
@NonNull |
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.
Non-public, not necessary.
/** | ||
* Holds onto a value along with time information. | ||
* | ||
* @param <T> the value type | ||
*/ | ||
public final class Timed<T> { | ||
@Nullable |
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 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) { |
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.
Why is this nullable?
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.
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) { |
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 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) { |
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 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) { |
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.
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) { |
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.
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) { |
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.
The e
argument should be @NonNull
.
@@ -31,13 +32,14 @@ | |||
*/ | |||
public abstract class GroupedObservable<K, T> extends Observable<T> { | |||
|
|||
@Nullable |
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.
No need to annotate this.
@@ -34,7 +35,7 @@ | |||
final boolean delayError; | |||
|
|||
static final int QUEUE_LINK_SIZE = 4; | |||
|
|||
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.
Whitespace added?
@@ -36,7 +35,7 @@ | |||
|
|||
@SuppressWarnings("rawtypes") | |||
static final AsyncSubscription[] TERMINATED = new AsyncSubscription[0]; | |||
|
|||
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.
Whitespace added?
@@ -44,6 +45,7 @@ public Timed(T value, long time, TimeUnit unit) { | |||
* Returns the contained value. | |||
* @return the contained value | |||
*/ | |||
@Nullable |
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 should be @NonNull
.
@@ -34,7 +34,7 @@ | |||
*/ | |||
@Experimental | |||
public final class SingleSubject<T> extends Single<T> implements SingleObserver<T> { | |||
|
|||
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.
Whitespace?
@@ -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) { |
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.
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) { |
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.
Nullable too.
@@ -47,7 +49,7 @@ | |||
* | |||
* @throws IllegalArgumentException if <code>exceptions</code> is empty. | |||
*/ | |||
public CompositeException(Throwable... exceptions) { | |||
public CompositeException(@NonNull Throwable... exceptions) { |
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.
Nullable instead? The code handles it explicitly.
Added nullability annotations to:
and some others