WIP:refactor
authorKai Moritz <kai@juplo.de>
Wed, 25 Jan 2023 16:45:59 +0000 (17:45 +0100)
committerKai Moritz <kai@juplo.de>
Wed, 25 Jan 2023 16:46:59 +0000 (17:46 +0100)
src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoom.java

index f5e3b06..a42434b 100644 (file)
@@ -70,7 +70,7 @@ public class ChatRoom
         .flatMap(existing -> text.equals(existing.getMessageText())
             ? Mono.just(existing)
             : Mono.error(() -> new MessageMutationException(existing, text)))
-        .switchIfEmpty(
+        .onErrorReturn(
             service
               .persistMessage(key, LocalDateTime.now(clock), text)
               .doOnNext(m ->
@@ -80,7 +80,7 @@ public class ChatRoom
                 {
                   log.warn("Emitting of message failed with {} for {}", result.name(), m);
                 }
-              }));
+              }).block());
   }