Skip to content

Commit 44c31a6

Browse files
baotrstoyanchev
authored andcommitted
Fix duplicate STOMP subscription id issue
Issue: SPR-15543
1 parent cb3d1be commit 44c31a6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,11 @@ public void updateAfterNewSubscription(String destination, String sessionId, Str
292292
String cachedDestination = entry.getKey();
293293
if (getPathMatcher().match(destination, cachedDestination)) {
294294
LinkedMultiValueMap<String, String> subs = entry.getValue();
295-
subs.add(sessionId, subsId);
296-
this.accessCache.put(cachedDestination, subs.deepCopy());
295+
// Subscription id's may also be populated via getSubscriptions()
296+
if (!subs.containsKey(sessionId) || !subs.get(sessionId).contains(subsId)) {
297+
subs.add(sessionId, subsId);
298+
this.accessCache.put(cachedDestination, subs.deepCopy());
299+
}
297300
}
298301
}
299302
}

0 commit comments

Comments
 (0)