Skip to content

Commit

Permalink
Fixed empty shared subscriptions list remaining forever in cache (#836)
Browse files Browse the repository at this point in the history
Even for clients that never made shared subscriptions, upon session clean,
an empty shared subscriptions list was created and never removed.
  • Loading branch information
hylkevds committed Apr 30, 2024
1 parent 858a0f3 commit 2092693
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Expand Up @@ -192,13 +192,13 @@ public String dumpTree() {

@Override
public void removeSharedSubscriptionsForClient(String clientId) {
List<SharedSubscription> sessionSharedSubscriptions = clientSharedSubscriptions
.computeIfAbsent(clientId, s -> Collections.emptyList());

// remove the client from all shared subscriptions
for (SharedSubscription subscription : sessionSharedSubscriptions) {
UnsubscribeRequest request = UnsubscribeRequest.buildShared(subscription.getShareName(), subscription.topicFilter(), clientId);
ctrie.removeFromTree(request);
List<SharedSubscription> sessionSharedSubscriptions = clientSharedSubscriptions.remove(clientId);
if (sessionSharedSubscriptions != null) {
// remove the client from all shared subscriptions
for (SharedSubscription subscription : sessionSharedSubscriptions) {
UnsubscribeRequest request = UnsubscribeRequest.buildShared(subscription.getShareName(), subscription.topicFilter(), clientId);
ctrie.removeFromTree(request);
}
}

subscriptionsRepository.removeAllSharedSubscriptions(clientId);
Expand Down
Expand Up @@ -81,7 +81,7 @@ public void removeSubscription(String topicFilter, String clientID) {
public void removeAllSharedSubscriptions(String clientId) {
final String sharedSubsMapName = sharedSubscriptions.get(clientId);
if (sharedSubsMapName == null) {
LOG.info("Removing all shared subscription of a non existing client: {}", clientId);
LOG.debug("Removing all shared subscription of a non existing client: {}", clientId);
return;
}
wipeAllSharedSubscripptions(clientId, sharedSubsMapName);
Expand Down

0 comments on commit 2092693

Please sign in to comment.