Skip to content

Commit 76e4d52

Browse files
authored
Adjust Flux#map mapper to disallow null return values (reactor#4103)
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
1 parent 1fe5a46 commit 76e4d52

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6623,7 +6623,7 @@ public final Flux<T> log(Logger logger,
66236623
*
66246624
* @return a transformed {@link Flux}
66256625
*/
6626-
public final <V> Flux<V> map(Function<? super T, ? extends @Nullable V> mapper) {
6626+
public final <V> Flux<V> map(Function<? super T, ? extends V> mapper) {
66276627
if (this instanceof Fuseable) {
66286628
return onAssembly(new FluxMapFuseable<>(this, mapper));
66296629
}

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import org.jspecify.annotations.Nullable;
2323
import org.reactivestreams.Subscription;
24-
import reactor.core.CorePublisher;
2524
import reactor.core.CoreSubscriber;
2625
import reactor.core.Fuseable;
2726

@@ -35,7 +34,7 @@
3534
*/
3635
final class FluxMap<T, R> extends InternalFluxOperator<T, R> {
3736

38-
final Function<? super T, ? extends @Nullable R> mapper;
37+
final Function<? super T, ? extends R> mapper;
3938

4039
/**
4140
* Constructs a FluxMap instance with the given source and mapper.
@@ -46,7 +45,7 @@ final class FluxMap<T, R> extends InternalFluxOperator<T, R> {
4645
* @throws NullPointerException if either {@code source} or {@code mapper} is null.
4746
*/
4847
FluxMap(Flux<? extends T> source,
49-
Function<? super T, ? extends @Nullable R> mapper) {
48+
Function<? super T, ? extends R> mapper) {
5049
super(source);
5150
this.mapper = Objects.requireNonNull(mapper, "mapper");
5251
}
@@ -72,14 +71,14 @@ static final class MapSubscriber<T, R>
7271
implements InnerOperator<T, R> {
7372

7473
final CoreSubscriber<? super R> actual;
75-
final Function<? super T, ? extends @Nullable R> mapper;
74+
final Function<? super T, ? extends R> mapper;
7675

7776
boolean done;
7877

7978
Subscription s;
8079

8180
MapSubscriber(CoreSubscriber<? super R> actual,
82-
Function<? super T, ? extends @Nullable R> mapper) {
81+
Function<? super T, ? extends R> mapper) {
8382
this.actual = actual;
8483
this.mapper = mapper;
8584
}

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import org.jspecify.annotations.Nullable;
2323
import org.reactivestreams.Subscription;
24-
import reactor.core.CorePublisher;
2524
import reactor.core.CoreSubscriber;
2625
import reactor.core.Fuseable;
2726

@@ -37,7 +36,7 @@
3736
*/
3837
final class FluxMapFuseable<T, R> extends InternalFluxOperator<T, R> implements Fuseable {
3938

40-
final Function<? super T, ? extends @Nullable R> mapper;
39+
final Function<? super T, ? extends R> mapper;
4140

4241
/**
4342
* Constructs a FluxMap instance with the given source and mapper.
@@ -48,7 +47,7 @@ final class FluxMapFuseable<T, R> extends InternalFluxOperator<T, R> implements
4847
* @throws NullPointerException if either {@code source} or {@code mapper} is null.
4948
*/
5049
FluxMapFuseable(Flux<? extends T> source,
51-
Function<? super T, ? extends @Nullable R> mapper) {
50+
Function<? super T, ? extends R> mapper) {
5251
super(source);
5352
this.mapper = Objects.requireNonNull(mapper, "mapper");
5453
}
@@ -83,7 +82,7 @@ static final class MapFuseableSubscriber<T, R>
8382
int sourceMode;
8483

8584
MapFuseableSubscriber(CoreSubscriber<? super R> actual,
86-
Function<? super T, ? extends @Nullable R> mapper) {
85+
Function<? super T, ? extends R> mapper) {
8786
this.actual = actual;
8887
this.mapper = mapper;
8988
}
@@ -242,7 +241,7 @@ static final class MapFuseableConditionalSubscriber<T, R>
242241
int sourceMode;
243242

244243
MapFuseableConditionalSubscriber(ConditionalSubscriber<? super R> actual,
245-
Function<? super T, ? extends @Nullable R> mapper) {
244+
Function<? super T, ? extends R> mapper) {
246245
this.actual = actual;
247246
this.mapper = mapper;
248247
}

0 commit comments

Comments
 (0)