Skip to content

More nullability annotations#5251

Merged
akarnokd merged 5 commits intoReactiveX:2.xfrom
mibac138:2.x
Apr 1, 2017
Merged

More nullability annotations#5251
akarnokd merged 5 commits intoReactiveX:2.xfrom
mibac138:2.x

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.

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.

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

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.

* @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.

* @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.

* @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.

* @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.

*/
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.

* @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.

* 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.

*/
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.


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?

@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?

* 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.

@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
* 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

* 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.

* @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