From 6034fdc4938a2ef062aefa84811736f3357953a1 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Mon, 15 May 2023 12:37:35 +0300 Subject: [PATCH] Fixed - name2entry.remove() invocation should be guarded by lock --- .../main/java/org/redisson/pubsub/PublishSubscribeService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/redisson/src/main/java/org/redisson/pubsub/PublishSubscribeService.java b/redisson/src/main/java/org/redisson/pubsub/PublishSubscribeService.java index 52326e519..c6d2ae531 100644 --- a/redisson/src/main/java/org/redisson/pubsub/PublishSubscribeService.java +++ b/redisson/src/main/java/org/redisson/pubsub/PublishSubscribeService.java @@ -544,7 +544,7 @@ public class PublishSubscribeService { } public CompletableFuture unsubscribe(ChannelName channelName, PubSubType topicType) { - Collection coll = name2entry.remove(channelName); + Collection coll = name2entry.get(channelName); if (coll == null || coll.isEmpty()) { RedisNodeNotFoundException ex = new RedisNodeNotFoundException("Node for name: " + channelName + " hasn't been discovered yet. Check cluster slots coverage using CLUSTER NODES command. Increase value of retryAttempts and/or retryInterval settings."); CompletableFuture promise = new CompletableFuture<>(); @@ -563,6 +563,7 @@ public class PublishSubscribeService { AsyncSemaphore lock = getSemaphore(channelName); CompletableFuture f = lock.acquire(); return f.thenCompose(v -> { + name2entry.remove(channelName); PubSubConnectionEntry entry = name2PubSubConnection.remove(new PubSubKey(channelName, e)); if (entry == null) { lock.release();