fix: `getChatRoomInfo()` thrwos `LoadInProgressException` when loading
authorKai Moritz <kai@juplo.de>
Sat, 3 Feb 2024 16:25:45 +0000 (17:25 +0100)
committerKai Moritz <kai@juplo.de>
Tue, 20 Feb 2024 09:35:33 +0000 (10:35 +0100)
- The method `InfoChannel.getChatRoomInfo(UUID)` has to check, if loading
  is in process.
- Otherwise, an existing chat-room might erronously not be found, if it is
  requested, while `InfoChannel` is loading, because it is not yet loaded.

src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/InfoChannel.java

index e6c18c7..2df7573 100644 (file)
@@ -1,6 +1,7 @@
 package de.juplo.kafka.chat.backend.implementation.kafka;
 
 import de.juplo.kafka.chat.backend.domain.ChatRoomInfo;
+import de.juplo.kafka.chat.backend.domain.exceptions.LoadInProgressException;
 import de.juplo.kafka.chat.backend.implementation.kafka.messages.AbstractMessageTo;
 import de.juplo.kafka.chat.backend.implementation.kafka.messages.info.EventChatRoomCreated;
 import de.juplo.kafka.chat.backend.implementation.kafka.messages.info.EventShardAssigned;
@@ -288,6 +289,11 @@ public class InfoChannel implements Runnable
 
   Mono<ChatRoomInfo> getChatRoomInfo(UUID id)
   {
+    if (loadInProgress)
+    {
+      return Mono.error(new LoadInProgressException());
+    }
+
     return Mono.fromSupplier(() -> chatRoomInfo.get(id));
   }