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

3.x: Add NonNull & SafeVarargs annotations + validator #6791

Merged
merged 1 commit into from
Dec 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
255 changes: 151 additions & 104 deletions src/main/java/io/reactivex/rxjava3/core/Completable.java

Large diffs are not rendered by default.

1,616 changes: 946 additions & 670 deletions src/main/java/io/reactivex/rxjava3/core/Flowable.java

Large diffs are not rendered by default.

564 changes: 304 additions & 260 deletions src/main/java/io/reactivex/rxjava3/core/Maybe.java

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/java/io/reactivex/rxjava3/core/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public final class Notification<T> {
final Object value;

/** Not meant to be implemented externally. */
private Notification(Object value) {
private Notification(@Nullable Object value) {
this.value = value;
}

Expand Down
309 changes: 147 additions & 162 deletions src/main/java/io/reactivex/rxjava3/core/Observable.java

Large diffs are not rendered by default.

487 changes: 260 additions & 227 deletions src/main/java/io/reactivex/rxjava3/core/Single.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,6 @@ public void mergeArrayNull() {
Flowable.mergeArray(128, 128, (Publisher<Object>[])null);
}

@SuppressWarnings("unchecked")
@Test(expected = NullPointerException.class)
public void mergeArrayOneIsNull() {
Flowable.mergeArray(128, 128, just1, null).blockingLast();
Expand Down Expand Up @@ -514,7 +513,6 @@ public void mergeDelayErrorArrayNull() {
Flowable.mergeArrayDelayError(128, 128, (Publisher<Object>[])null);
}

@SuppressWarnings("unchecked")
@Test(expected = NullPointerException.class)
public void mergeDelayErrorArrayOneIsNull() {
Flowable.mergeArrayDelayError(128, 128, just1, null).blockingLast();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,6 @@ public void arrayDelayErrorMaxConcurrency() {
PublishProcessor<Integer> pp2 = PublishProcessor.create();
PublishProcessor<Integer> pp3 = PublishProcessor.create();

@SuppressWarnings("unchecked")
TestSubscriber<Integer> ts = Flowable.concatArrayEagerDelayError(2, 2, pp1, pp2, pp3)
.test();

Expand Down Expand Up @@ -1246,7 +1245,6 @@ public void arrayDelayErrorMaxConcurrencyErrorDelayed() {
PublishProcessor<Integer> pp2 = PublishProcessor.create();
PublishProcessor<Integer> pp3 = PublishProcessor.create();

@SuppressWarnings("unchecked")
TestSubscriber<Integer> ts = Flowable.concatArrayEagerDelayError(2, 2, pp1, pp2, pp3)
.test();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,6 @@ public void array() {
}
}

@SuppressWarnings("unchecked")
@Test
public void mergeArrayDelayError() {
Flowable.mergeArrayDelayError(Flowable.just(1), Flowable.just(2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,6 @@ public void array() {
}
}

@SuppressWarnings("unchecked")
@Test
public void mergeArray2() {
Flowable.mergeArray(Flowable.just(1), Flowable.just(2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,6 @@ public void run() {
public void longFlow() {
Flowable.range(1, 1000000)
.publish(new Function<Flowable<Integer>, Publisher<Integer>>() {
@SuppressWarnings("unchecked")
@Override
public Publisher<Integer> apply(Flowable<Integer> v) throws Exception {
return Flowable.mergeArray(
Expand All @@ -491,7 +490,6 @@ public boolean test(Integer w) throws Exception {
public void longFlow2() {
Flowable.range(1, 100000)
.publish(new Function<Flowable<Integer>, Publisher<Integer>>() {
@SuppressWarnings("unchecked")
@Override
public Publisher<Integer> apply(Flowable<Integer> v) throws Exception {
return Flowable.mergeArray(
Expand Down Expand Up @@ -519,7 +517,6 @@ public boolean test(Integer w) throws Exception {
public void longFlowHidden() {
Flowable.range(1, 1000000).hide()
.publish(new Function<Flowable<Integer>, Publisher<Integer>>() {
@SuppressWarnings("unchecked")
@Override
public Publisher<Integer> apply(Flowable<Integer> v) throws Exception {
return Flowable.mergeArray(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ public void run() {

@Test
public void disposeNoFurtherSignals() {
@SuppressWarnings("unchecked")
TestObserver<Integer> to = Maybe.ambArray(new Maybe<Integer>() {
@Override
protected void subscribeActual(
Expand All @@ -134,7 +133,6 @@ protected void subscribeActual(
to.assertResult(1);
}

@SuppressWarnings("unchecked")
@Test
public void noWinnerSuccessDispose() throws Exception {
for (int i = 0; i < TestHelper.RACE_LONG_LOOPS; i++) {
Expand All @@ -160,7 +158,6 @@ public void accept(Object v) throws Exception {
}
}

@SuppressWarnings("unchecked")
@Test
public void noWinnerErrorDispose() throws Exception {
final TestException ex = new TestException();
Expand All @@ -187,7 +184,6 @@ public void accept(Throwable e) throws Exception {
}
}

@SuppressWarnings("unchecked")
@Test
public void noWinnerCompleteDispose() throws Exception {
for (int i = 0; i < TestHelper.RACE_LONG_LOOPS; i++) {
Expand Down Expand Up @@ -223,7 +219,6 @@ public void nullSourceSuccessRace() {
final Subject<Integer> ps = ReplaySubject.create();
ps.onNext(1);

@SuppressWarnings("unchecked")
final Maybe<Integer> source = Maybe.ambArray(ps.singleElement(),
Maybe.<Integer>never(), Maybe.<Integer>never(), null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

public class MaybeConcatArrayTest extends RxJavaTest {

@SuppressWarnings("unchecked")
@Test
public void cancel() {
Maybe.concatArray(Maybe.just(1), Maybe.just(2))
Expand All @@ -38,7 +37,6 @@ public void cancel() {
.assertResult(1);
}

@SuppressWarnings("unchecked")
@Test
public void cancelDelayError() {
Maybe.concatArrayDelayError(Maybe.just(1), Maybe.just(2))
Expand All @@ -47,7 +45,6 @@ public void cancelDelayError() {
.assertResult(1);
}

@SuppressWarnings("unchecked")
@Test
public void backpressure() {
TestSubscriber<Integer> ts = Maybe.concatArray(Maybe.just(1), Maybe.just(2))
Expand All @@ -64,7 +61,6 @@ public void backpressure() {
ts.assertResult(1, 2);
}

@SuppressWarnings("unchecked")
@Test
public void backpressureDelayError() {
TestSubscriber<Integer> ts = Maybe.concatArrayDelayError(Maybe.just(1), Maybe.just(2))
Expand All @@ -81,7 +77,6 @@ public void backpressureDelayError() {
ts.assertResult(1, 2);
}

@SuppressWarnings("unchecked")
@Test
public void requestCancelRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
Expand All @@ -106,7 +101,6 @@ public void run() {
}
}

@SuppressWarnings("unchecked")
@Test
public void requestCancelRaceDelayError() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
Expand All @@ -131,7 +125,6 @@ public void run() {
}
}

@SuppressWarnings("unchecked")
@Test
public void errorAfterTermination() {
List<Throwable> errors = TestHelper.trackPluginErrors();
Expand All @@ -158,7 +151,6 @@ protected void subscribeActual(MaybeObserver<? super Integer> observer) {
}
}

@SuppressWarnings("unchecked")
@Test
public void noSubsequentSubscription() {
final int[] calls = { 0 };
Expand All @@ -178,7 +170,6 @@ public void subscribe(MaybeEmitter<Integer> s) throws Exception {
assertEquals(1, calls[0]);
}

@SuppressWarnings("unchecked")
@Test
public void noSubsequentSubscriptionDelayError() {
final int[] calls = { 0 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

public class MaybeMergeArrayTest extends RxJavaTest {

@SuppressWarnings("unchecked")
@Test
public void normal() {
TestSubscriberEx<Integer> ts = new TestSubscriberEx<Integer>().setInitialFusionMode(QueueFuseable.SYNC);
Expand All @@ -45,7 +44,6 @@ public void normal() {
.assertResult(1, 2);
}

@SuppressWarnings("unchecked")
@Test
public void fusedPollMixed() {
TestSubscriberEx<Integer> ts = new TestSubscriberEx<Integer>().setInitialFusionMode(QueueFuseable.ANY);
Expand Down Expand Up @@ -92,7 +90,6 @@ public void onComplete() {
});
}

@SuppressWarnings("unchecked")
@Test
public void cancel() {
TestSubscriber<Integer> ts = new TestSubscriber<>(0L);
Expand All @@ -106,7 +103,6 @@ public void cancel() {
ts.assertEmpty();
}

@SuppressWarnings("unchecked")
@Test
public void firstErrors() {
TestSubscriber<Integer> ts = new TestSubscriber<>(0L);
Expand All @@ -117,7 +113,6 @@ public void firstErrors() {
ts.assertFailure(TestException.class);
}

@SuppressWarnings("unchecked")
@Test
public void errorFused() {
TestSubscriberEx<Integer> ts = new TestSubscriberEx<Integer>().setInitialFusionMode(QueueFuseable.ANY);
Expand All @@ -130,7 +125,6 @@ public void errorFused() {
.assertFailure(TestException.class);
}

@SuppressWarnings("unchecked")
@Test
public void errorRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
Expand Down Expand Up @@ -172,7 +166,6 @@ public void run() {
}
}

@SuppressWarnings("unchecked")
@Test
public void mergeBadSource() {
Maybe.mergeArray(new Maybe<Integer>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ public void run() {
}
}

@SuppressWarnings("unchecked")
@Test(expected = NullPointerException.class)
public void zipArrayOneIsNull() {
Maybe.zipArray(new Function<Object[], Object>() {
Expand All @@ -163,7 +162,6 @@ public Object apply(Object[] v) {
.blockingGet();
}

@SuppressWarnings("unchecked")
@Test
public void singleSourceZipperReturnsNull() {
Maybe.zipArray(Functions.justFunction(null), Maybe.just(1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ public Object apply(Object[] v) {
.blockingGet();
}

@SuppressWarnings("unchecked")
@Test
public void singleSourceZipperReturnsNull() {
Maybe.zipArray(Functions.justFunction(null), Maybe.just(1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ public void cancelNoConcurrentClean() {
public void checkUnboundedInnerQueue() {
MaybeSubject<Integer> ms = MaybeSubject.create();

@SuppressWarnings("unchecked")
TestObserver<Integer> to = Observable
.fromArray(ms, Maybe.just(2), Maybe.just(3), Maybe.just(4))
.concatMapMaybe(Functions.<Maybe<Integer>>identity(), 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ public void cancelNoConcurrentClean() {
public void checkUnboundedInnerQueue() {
SingleSubject<Integer> ss = SingleSubject.create();

@SuppressWarnings("unchecked")
TestObserver<Integer> to = Observable
.fromArray(ss, Single.just(2), Single.just(3), Single.just(4))
.concatMapSingle(Functions.<Single<Integer>>identity(), 2)
Expand Down
Loading