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 fde41c5d7..1fb2f87fb 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/MessagesCache.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/MessagesCache.java @@ -384,12 +384,13 @@ public class MessagesCache extends RedisClusterPubSubAdapter imp } public void removeMessageAvailabilityListener(final MessageAvailabilityListener listener) { - @Nullable final String queueName = queueNamesByMessageListener.remove(listener); + @Nullable final String queueName = queueNamesByMessageListener.get(listener); if (queueName != null) { unsubscribeFromKeyspaceNotifications(queueName); synchronized (messageListenersByQueueName) { + queueNamesByMessageListener.remove(listener); messageListenersByQueueName.remove(queueName); } }