Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPR-15543: Fix duplicate subscriptionId for destination-sessionId key #1427

Closed
wants to merge 1 commit into from

Conversation

baot
Copy link
Contributor

@baot baot commented May 14, 2017

DefaultSubscriptionRegistry's destinationCache accessCache contains duplicate subscriptionId for destination - sessionId key if findSubscriptions is called after addSubscription and before updateAfterNewSubscription.

The change includes checking for existing subId in updateAfterNewSubscription method before adding subId value to sessionId key. (Set implementation to avoid duplication can be considered or other better solutions are appreciated).

Issue: SPR-15543

I have submitted CLA.

@rstoyanchev
Copy link
Contributor

This is now merged.

@steviemo
Copy link

Is there not possible NPE if subs.get(sessionId) returns null? How about:

final LinkedMultiValueMap<String, String> subs = entry.getValue();
final List subscriptionsForSession = subs.get(sessionId);
if (null == subscriptionsForSession || !subscriptionsForSession.contains(subsId)) {
subs.add(sessionId, subsId);
}
this.accessCache.put(cachedDestination, subs.deepCopy());

@@ -292,8 +292,10 @@ public void updateAfterNewSubscription(String destination, String sessionId, Str
String cachedDestination = entry.getKey();
if (getPathMatcher().match(destination, cachedDestination)) {
LinkedMultiValueMap<String, String> subs = entry.getValue();
subs.add(sessionId, subsId);
this.accessCache.put(cachedDestination, subs.deepCopy());
if (!subs.containsKey(sessionId) || !subs.get(sessionId).contains(subsId)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在这里加了一个判断,表示没看懂为什么要加这个判断

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, thanks for catching this. Fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants