From e9fd32de791aa95ccfd8adf9959ba789fcefb432 Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Tue, 26 Jul 2022 12:17:12 -0500 Subject: [PATCH] Only attempt to unsubscribe if the queue name is not null --- .../textsecuregcm/storage/MessagesCache.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/MessagesCache.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/MessagesCache.java index 17938f661..3157e4fb9 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/MessagesCache.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/MessagesCache.java @@ -36,6 +36,7 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.stream.Collectors; +import javax.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.whispersystems.textsecuregcm.entities.MessageProtos; @@ -309,12 +310,12 @@ public class MessagesCache extends RedisClusterPubSubAdapter imp } public void removeMessageAvailabilityListener(final MessageAvailabilityListener listener) { - final String queueName = queueNamesByMessageListener.remove(listener); + @Nullable final String queueName = queueNamesByMessageListener.remove(listener); - unsubscribeFromKeyspaceNotifications(queueName); + if (queueName != null) { + unsubscribeFromKeyspaceNotifications(queueName); - synchronized (messageListenersByQueueName) { - if (queueName != null) { + synchronized (messageListenersByQueueName) { messageListenersByQueueName.remove(queueName); } }