From 643552ccd8a18ffcac2c108a9cb4f88f6c70b19f Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 3 Feb 2024 17:25:45 +0100 Subject: [PATCH] fix: `getChatRoomInfo()` thrwos `LoadInProgressException` when loading - 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. --- .../chat/backend/implementation/kafka/InfoChannel.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/InfoChannel.java b/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/InfoChannel.java index e6c18c77..2df7573c 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/InfoChannel.java +++ b/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/InfoChannel.java @@ -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 getChatRoomInfo(UUID id) { + if (loadInProgress) + { + return Mono.error(new LoadInProgressException()); + } + return Mono.fromSupplier(() -> chatRoomInfo.get(id)); } -- 2.20.1