Skip to content

Commit 31be3c0

Browse files
authored
Migrate nullability annotations to JSpecify (#381)
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
1 parent cdafee7 commit 31be3c0

27 files changed

+198
-64
lines changed

build.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,6 @@ configure(subprojects) { project ->
140140
dependencies {
141141
api libs.reactorCore
142142

143-
// JSR-305 annotations
144-
compileOnly libs.jsr305
145-
testCompileOnly libs.jsr305
146-
147143
// Logging
148144
compileOnly libs.slf4j
149145
testCompileOnly libs.slf4j

reactor-adapter/src/main/java/reactor/adapter/rxjava/RxJava2Adapter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016-2021 VMware Inc. or its affiliates, All Rights Reserved.
2+
* Copyright (c) 2016-2025 VMware Inc. or its affiliates, All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
3131
import io.reactivex.disposables.Disposable;
3232
import io.reactivex.internal.operators.completable.CompletableFromPublisher;
3333
import io.reactivex.internal.operators.single.SingleFromPublisher;
34+
import org.jspecify.annotations.Nullable;
3435
import org.reactivestreams.Publisher;
3536
import org.reactivestreams.Subscriber;
3637
import org.reactivestreams.Subscription;
@@ -422,7 +423,7 @@ public void cancel() {
422423
}
423424

424425
@Override
425-
public T poll() {
426+
public @Nullable T poll() {
426427
return qs.poll();
427428
}
428429

reactor-adapter/src/main/java/reactor/adapter/rxjava/RxJava3Adapter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020-2021 VMware Inc. or its affiliates, All Rights Reserved.
2+
* Copyright (c) 2020-2025 VMware Inc. or its affiliates, All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
2020
import java.util.function.Consumer;
2121

2222
import io.reactivex.rxjava3.annotations.NonNull;
23+
import io.reactivex.rxjava3.annotations.Nullable;
2324
import io.reactivex.rxjava3.core.BackpressureStrategy;
2425
import io.reactivex.rxjava3.core.Completable;
2526
import io.reactivex.rxjava3.core.CompletableObserver;
@@ -459,7 +460,7 @@ public void cancel() {
459460
}
460461

461462
@Override
462-
public T poll() {
463+
public @Nullable T poll() {
463464
return qs.poll();
464465
}
465466

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
1+
/*
2+
* Copyright (c) 2025 VMware Inc. or its affiliates, All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
/**
218
* Adapters between RxJava classes (both 2.x and 3.x) and Reactor classes.
319
*/
4-
@NonNullApi
20+
@NullMarked
521
package reactor.adapter.rxjava;
622

7-
import reactor.util.annotation.NonNullApi;
23+
import org.jspecify.annotations.NullMarked;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) 2025 VMware Inc. or its affiliates, All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
@NullMarked
18+
package reactor.bool;
19+
20+
import org.jspecify.annotations.NullMarked;
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1+
/*
2+
* Copyright (c) 2025 VMware Inc. or its affiliates, All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
/**
218
* Extra utilities around caching, providing a default go-to strategy on what to store
319
* in a cache.
420
*/
5-
@NonNullApi
21+
@NullMarked
622
package reactor.cache;
723

8-
import reactor.util.annotation.NonNullApi;
24+
import org.jspecify.annotations.NullMarked;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) 2025 VMware Inc. or its affiliates, All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
@NullMarked
18+
package reactor.function;
19+
20+
import org.jspecify.annotations.NullMarked;

reactor-extra/src/main/java/reactor/math/MathSubscriber.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017-2021 VMware Inc. or its affiliates, All Rights Reserved.
2+
* Copyright (c) 2017-2025 VMware Inc. or its affiliates, All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,12 +16,14 @@
1616

1717
package reactor.math;
1818

19+
import org.jspecify.annotations.Nullable;
1920
import org.reactivestreams.Subscription;
2021
import reactor.core.CoreSubscriber;
2122
import reactor.core.publisher.Operators;
2223

2324
abstract class MathSubscriber<T, R> extends Operators.MonoSubscriber<T, R> {
2425

26+
@SuppressWarnings("DataFlowIssue") // s is initialized in onSubscribe
2527
Subscription s;
2628

2729
boolean done;
@@ -91,7 +93,7 @@ public void cancel() {
9193

9294
protected abstract void reset();
9395

94-
protected abstract R result();
96+
protected abstract @Nullable R result();
9597

9698
protected abstract void updateResult(T newValue);
9799
}

reactor-extra/src/main/java/reactor/math/MonoAverageBigDecimal.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017-2021 VMware Inc. or its affiliates, All Rights Reserved.
2+
* Copyright (c) 2017-2025 VMware Inc. or its affiliates, All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
2020
import java.math.BigInteger;
2121
import java.util.function.Function;
2222

23+
import org.jspecify.annotations.Nullable;
2324
import org.reactivestreams.Publisher;
2425
import reactor.core.CoreSubscriber;
2526
import reactor.core.Fuseable;
@@ -68,7 +69,7 @@ protected void reset() {
6869
}
6970

7071
@Override
71-
protected BigDecimal result() {
72+
protected @Nullable BigDecimal result() {
7273
return (count == 0 ? null : sum.divide(BigDecimal.valueOf(count)));
7374
}
7475

reactor-extra/src/main/java/reactor/math/MonoAverageBigInteger.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017-2021 VMware Inc. or its affiliates, All Rights Reserved.
2+
* Copyright (c) 2017-2025 VMware Inc. or its affiliates, All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
2121
import java.math.RoundingMode;
2222
import java.util.function.Function;
2323

24+
import org.jspecify.annotations.Nullable;
2425
import org.reactivestreams.Publisher;
2526
import reactor.core.CoreSubscriber;
2627
import reactor.core.Fuseable;
@@ -69,7 +70,7 @@ protected void reset() {
6970
}
7071

7172
@Override
72-
protected BigInteger result() {
73+
protected @Nullable BigInteger result() {
7374
return (count == 0 ? null : sum.divide(BigDecimal.valueOf(count), RoundingMode.FLOOR).toBigInteger());
7475
}
7576

0 commit comments

Comments
 (0)