From 79e98554981d6270f70d07e599b73c21c1332a98 Mon Sep 17 00:00:00 2001 From: Johannes Schneider Date: Fri, 3 Feb 2017 12:20:21 +0100 Subject: [PATCH] add annotations and assert to help static code analysis --- .../observable/ObservableWithLatestFromMany.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableWithLatestFromMany.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableWithLatestFromMany.java index 21d5c8f975..c7eaaafebe 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableWithLatestFromMany.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableWithLatestFromMany.java @@ -16,6 +16,8 @@ import java.util.concurrent.atomic.*; import io.reactivex.*; +import io.reactivex.annotations.NonNull; +import io.reactivex.annotations.Nullable; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.Exceptions; import io.reactivex.functions.Function; @@ -33,20 +35,23 @@ */ public final class ObservableWithLatestFromMany extends AbstractObservableWithUpstream { + @Nullable final ObservableSource[] otherArray; + @Nullable final Iterable> otherIterable; + @NonNull final Function combiner; - public ObservableWithLatestFromMany(ObservableSource source, ObservableSource[] otherArray, Function combiner) { + public ObservableWithLatestFromMany(@NonNull ObservableSource source, @NonNull ObservableSource[] otherArray, @NonNull Function combiner) { super(source); this.otherArray = otherArray; this.otherIterable = null; this.combiner = combiner; } - public ObservableWithLatestFromMany(ObservableSource source, Iterable> otherIterable, Function combiner) { + public ObservableWithLatestFromMany(@NonNull ObservableSource source, @NonNull Iterable> otherIterable, @NonNull Function combiner) { super(source); this.otherArray = null; this.otherIterable = otherIterable; @@ -58,6 +63,7 @@ protected void subscribeActual(Observer s) { ObservableSource[] others = otherArray; int n = 0; if (others == null) { + assert otherIterable!=null; others = new ObservableSource[8]; try {