Skip to content

Commit b37d11a

Browse files
chemicLbjmi
andauthored
Adjust Mono methods: fromCallable and fromSupplier nullability (#4116)
Co-authored-by: Björn Michael <[email protected]> Signed-off-by: Dariusz Jędrzejczyk <[email protected]>
1 parent 64e214d commit b37d11a

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

reactor-core/src/main/java/reactor/core/publisher/Mono.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,13 +515,13 @@ public static <T> Mono<T> from(Publisher<? extends T> source) {
515515
* <p>
516516
* <img class="marble" src="doc-files/marbles/fromCallable.svg" alt="">
517517
* <p>
518-
* @param supplier {@link Callable} that will produce the value
518+
* @param callable {@link Callable} that will produce the value
519519
* @param <T> type of the expected value
520520
*
521521
* @return A {@link Mono}.
522522
*/
523-
public static <T> Mono<T> fromCallable(Callable<? extends T> supplier) {
524-
return onAssembly(new MonoCallable<>(supplier));
523+
public static <T> Mono<T> fromCallable(Callable<? extends @Nullable T> callable) {
524+
return onAssembly(new MonoCallable<>(callable));
525525
}
526526

527527
/**
@@ -709,7 +709,7 @@ public static <T> Mono<T> fromRunnable(Runnable runnable) {
709709
*
710710
* @return A {@link Mono}.
711711
*/
712-
public static <T> Mono<T> fromSupplier(Supplier<? extends T> supplier) {
712+
public static <T> Mono<T> fromSupplier(Supplier<? extends @Nullable T> supplier) {
713713
return onAssembly(new MonoSupplier<>(supplier));
714714
}
715715

reactor-core/src/main/java/reactor/core/publisher/MonoCallable.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
final class MonoCallable<T> extends Mono<T>
3838
implements Callable<T>, Fuseable, SourceProducer<T> {
3939

40-
final Callable<? extends T> callable;
40+
final Callable<? extends @Nullable T> callable;
4141

42-
MonoCallable(Callable<? extends T> callable) {
42+
MonoCallable(Callable<? extends @Nullable T> callable) {
4343
this.callable = Objects.requireNonNull(callable, "callable");
4444
}
4545

@@ -55,7 +55,7 @@ public void subscribe(CoreSubscriber<? super T> actual) {
5555
}
5656

5757
@Override
58-
public T block(Duration m) {
58+
public @Nullable T block(Duration m) {
5959
try {
6060
return callable.call();
6161
}
@@ -65,7 +65,7 @@ public T block(Duration m) {
6565
}
6666

6767
@Override
68-
public T call() throws Exception {
68+
public @Nullable T call() throws Exception {
6969
return callable.call();
7070
}
7171

@@ -79,7 +79,7 @@ static class MonoCallableSubscription<T>
7979
implements InnerProducer<T>, Fuseable, QueueSubscription<T> {
8080

8181
final CoreSubscriber<? super T> actual;
82-
final Callable<? extends T> callable;
82+
final Callable<? extends @Nullable T> callable;
8383

8484
boolean done;
8585

@@ -91,7 +91,7 @@ static class MonoCallableSubscription<T>
9191

9292
volatile boolean cancelled;
9393

94-
MonoCallableSubscription(CoreSubscriber<? super T> actual, Callable<? extends T> callable) {
94+
MonoCallableSubscription(CoreSubscriber<? super T> actual, Callable<? extends @Nullable T> callable) {
9595
this.actual = actual;
9696
this.callable = callable;
9797
}

reactor-core/src/main/java/reactor/core/publisher/MonoSupplier.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ final class MonoSupplier<T>
3636
extends Mono<T>
3737
implements Callable<T>, Fuseable, SourceProducer<T> {
3838

39-
final Supplier<? extends T> supplier;
39+
final Supplier<? extends @Nullable T> supplier;
4040

41-
MonoSupplier(Supplier<? extends T> callable) {
42-
this.supplier = Objects.requireNonNull(callable, "callable");
41+
MonoSupplier(Supplier<? extends @Nullable T> supplier) {
42+
this.supplier = Objects.requireNonNull(supplier, "supplier");
4343
}
4444

4545
@Override
@@ -73,7 +73,7 @@ static class MonoSupplierSubscription<T>
7373
implements InnerProducer<T>, Fuseable, QueueSubscription<T> {
7474

7575
final CoreSubscriber<? super T> actual;
76-
final Supplier<? extends T> supplier;
76+
final Supplier<? extends @Nullable T> supplier;
7777

7878
boolean done;
7979

@@ -84,9 +84,10 @@ static class MonoSupplierSubscription<T>
8484

8585
volatile boolean cancelled;
8686

87-
MonoSupplierSubscription(CoreSubscriber<? super T> actual, Supplier<? extends T> callable) {
87+
MonoSupplierSubscription(CoreSubscriber<? super T> actual,
88+
Supplier<? extends @Nullable T> supplier) {
8889
this.actual = actual;
89-
this.supplier = callable;
90+
this.supplier = supplier;
9091
}
9192

9293
@Override

0 commit comments

Comments
 (0)