first of all... i am new to Reactive programming and WebFlux.
I am Using WebClient to execute a PATH request:
webClient.patch().uri("/documents/" + document.getIddocument())
.headers(h -> h.setBearerAuth(bearerToken)).body(Mono.just(map), Map.class).retrieve()
.onStatus(httpStatus -> !httpStatus.is2xxSuccessful(),
clientResponse -> handleErrorResponse(clientResponse))
.bodyToMono(String.class).defaultIfEmpty("EMPTY PATCH RESPONSE")
.filter(response -> !Objects.isNull(response)).subscribe(body -> logger.info("PATCH response: " + body));
The patch is executed OK and everything works (I see in my logs the PATCH response content) but both in Unit Tests and once deployed I get this exception (not linked to my code):
2024-02-08T14:17:27.964+01:00 ERROR 1 --- [or-http-epoll-2] reactor.core.publisher.Operators : Operator called default onErrorDropped
reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.NullPointerException: The mapper returned a null Mono
Caused by: java.lang.NullPointerException: The mapper returned a null Mono
at java.base/java.util.Objects.requireNonNull(Objects.java:233) ~[na:na]
at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:132) ~[reactor-core-3.5.14.jar:3.5.14]
at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:158) ~[reactor-core-3.5.14.jar:3.5.14]
at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.complete(MonoIgnoreThen.java:292) ~[reactor-core-3.5.14.jar:3.5.14]
at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onNext(MonoIgnoreThen.java:187) ~[reactor-core-3.5.14.jar:3.5.14]
at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:236) ~[reactor-core-3.5.14.jar:3.5.14]
at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onComplete(MonoIgnoreThen.java:203) ~[reactor-core-3.5.14.jar:3.5.14]
at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144) ~[reactor-core-3.5.14.jar:3.5.14]
at reactor.core.publisher.FluxCreate$BaseSink.complete(FluxCreate.java:463) ~[reactor-core-3.5.14.jar:3.5.14]
at reactor.core.publisher.FluxCreate$BufferAsyncSink.drain(FluxCreate.java:869) ~[reactor-core-3.5.14.jar:3.5.14]
at reactor.core.publisher.FluxCreate$BufferAsyncSink.complete(FluxCreate.java:817) ~[reactor-core-3.5.14.jar:3.5.14]
at reactor.core.publisher.FluxCreate$SerializedFluxSink.drainLoop(FluxCreate.java:247) ~[reactor-core-3.5.14.jar:3.5.14]
at reactor.core.publisher.FluxCreate$SerializedFluxSink.drain(FluxCreate.java:213) ~[reactor-core-3.5.14.jar:3.5.14]
at reactor.core.publisher.FluxCreate$SerializedFluxSink.complete(FluxCreate.java:204) ~[reactor-core-3.5.14.jar:3.5.14]
at org.springframework.core.io.buffer.DataBufferUtils$WritableByteChannelSubscriber.hookOnComplete(DataBufferUtils.java:1091) ~[spring-core-6.0.16.jar:6.0.16]
Not critical but I hate finding this every iteration of the PATCH in my logs, specially if everything is working fine.