diff --git a/src/main/java/org/redisson/connection/PubSubConnectionEntry.java b/src/main/java/org/redisson/connection/PubSubConnectionEntry.java index cd6396e9c..9d83363f3 100644 --- a/src/main/java/org/redisson/connection/PubSubConnectionEntry.java +++ b/src/main/java/org/redisson/connection/PubSubConnectionEntry.java @@ -76,12 +76,17 @@ public class PubSubConnectionEntry { } } + boolean deleted = false; synchronized (queue) { if (channelListeners.get(channelName) != queue) { - addListener(channelName, listener); - return; + deleted = true; + } else { + queue.add(listener); } - queue.add(listener); + } + if (deleted) { + addListener(channelName, listener); + return; } conn.addListener(listener);