fix: `ChatRoomData` must only be activated after restoring completes
authorKai Moritz <kai@juplo.de>
Thu, 14 Mar 2024 11:49:29 +0000 (12:49 +0100)
committerKai Moritz <kai@juplo.de>
Fri, 22 Mar 2024 16:39:20 +0000 (17:39 +0100)
src/main/java/de/juplo/kafka/chat/backend/implementation/inmemory/SimpleChatHomeService.java

index 8e3cc43..e78b049 100644 (file)
@@ -81,10 +81,11 @@ public class SimpleChatHomeService implements ChatHomeService
                   clock,
                   chatMessageService,
                   historyLimit);
-          chatRoomData.activate();
           this.chatRoomData.put(info.getId(), chatRoomData);
 
-          return chatMessageService.restore(storageStrategy);
+          return chatMessageService
+              .restore(storageStrategy)
+              .doOnSuccess(noResult -> chatRoomData.activate());
         })
         .count()
         .doOnSuccess(count -> log.info("Restored {} with {} chat-rooms", this, count))