From: Kai Moritz Date: Thu, 14 Mar 2024 11:49:29 +0000 (+0100) Subject: fix: `ChatRoomData` must only be activated after restoring completes X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=7c085ad58c3b99a48de8b88d9c251f21531c72e0;p=demos%2Fkafka%2Fchat fix: `ChatRoomData` must only be activated after restoring completes --- diff --git a/src/main/java/de/juplo/kafka/chat/backend/implementation/inmemory/SimpleChatHomeService.java b/src/main/java/de/juplo/kafka/chat/backend/implementation/inmemory/SimpleChatHomeService.java index 8e3cc430..e78b049b 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/implementation/inmemory/SimpleChatHomeService.java +++ b/src/main/java/de/juplo/kafka/chat/backend/implementation/inmemory/SimpleChatHomeService.java @@ -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))