import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.Sinks;
+import reactor.core.publisher.SynchronousSink;
import java.time.Clock;
import java.time.LocalDateTime;
Message.MessageKey key = Message.MessageKey.of(user, id);
- Mono<Message> mono = service
+ return service
.getMessage(key)
- .handle((existing, sink) ->
+ .handle((Message existing, SynchronousSink<Message> sink) ->
{
if (existing.getMessageText().equals(text))
{
{
sink.error(new MessageMutationException(existing, text));
}
- });
-
- return mono.switchIfEmpty(Mono.defer(() -> service
+ })
+ .switchIfEmpty(Mono.defer(() -> service
.persistMessage(key, LocalDateTime.now(clock), text)
.doOnNext(m ->
{