Polish
This commit is contained in:
@@ -187,25 +187,25 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
|
||||
synchronized (this.updateCache) {
|
||||
Set<String> destinationsToRemove = new HashSet<String>();
|
||||
for (Map.Entry<String, MultiValueMap<String, String>> entry : this.updateCache.entrySet()) {
|
||||
String cachedDestination = entry.getKey();
|
||||
MultiValueMap<String, String> subs = entry.getValue();
|
||||
List<String> subsIds = subs.get(sessionId);
|
||||
if(subsIds != null) {
|
||||
subsIds.remove(subsId);
|
||||
if (subsIds.isEmpty()) {
|
||||
subs.remove(sessionId);
|
||||
String destination = entry.getKey();
|
||||
MultiValueMap<String, String> sessionMap = entry.getValue();
|
||||
List<String> subscriptions = sessionMap.get(sessionId);
|
||||
if (subscriptions != null) {
|
||||
subscriptions.remove(subsId);
|
||||
if (subscriptions.isEmpty()) {
|
||||
sessionMap.remove(sessionId);
|
||||
}
|
||||
if (subs.isEmpty()) {
|
||||
destinationsToRemove.add(cachedDestination);
|
||||
if (sessionMap.isEmpty()) {
|
||||
destinationsToRemove.add(destination);
|
||||
}
|
||||
else {
|
||||
this.accessCache.put(cachedDestination, new LinkedMultiValueMap<String, String>(subs));
|
||||
this.accessCache.put(destination, new LinkedMultiValueMap<String, String>(sessionMap));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String destinationToRemove : destinationsToRemove) {
|
||||
this.updateCache.remove(destinationToRemove);
|
||||
this.accessCache.remove(destinationToRemove);
|
||||
for (String destination : destinationsToRemove) {
|
||||
this.updateCache.remove(destination);
|
||||
this.accessCache.remove(destination);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,20 +214,20 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
|
||||
synchronized (this.updateCache) {
|
||||
Set<String> destinationsToRemove = new HashSet<String>();
|
||||
for (Map.Entry<String, MultiValueMap<String, String>> entry : this.updateCache.entrySet()) {
|
||||
String cachedDestination = entry.getKey();
|
||||
MultiValueMap<String, String> subs = entry.getValue();
|
||||
if(subs.remove(info.getSessionId()) != null) {
|
||||
if (subs.isEmpty()) {
|
||||
destinationsToRemove.add(cachedDestination);
|
||||
String destination = entry.getKey();
|
||||
MultiValueMap<String, String> sessionMap = entry.getValue();
|
||||
if (sessionMap.remove(info.getSessionId()) != null) {
|
||||
if (sessionMap.isEmpty()) {
|
||||
destinationsToRemove.add(destination);
|
||||
}
|
||||
else {
|
||||
this.accessCache.put(cachedDestination,new LinkedMultiValueMap<String, String>(subs));
|
||||
this.accessCache.put(destination, new LinkedMultiValueMap<String, String>(sessionMap));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String d : destinationsToRemove) {
|
||||
this.updateCache.remove(d);
|
||||
this.accessCache.remove(d);
|
||||
for (String destination : destinationsToRemove) {
|
||||
this.updateCache.remove(destination);
|
||||
this.accessCache.remove(destination);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,8 +279,13 @@ public class DefaultSubscriptionRegistryTests {
|
||||
this.registry.registerSubscription(subscribeMessage("sess01", "subs02", "/foo"));
|
||||
MultiValueMap<String, String> actual = this.registry.findSubscriptions(message("/foo"));
|
||||
assertEquals("Expected 1 element", 1, actual.size());
|
||||
assertEquals(Arrays.asList("subs01", "subs02"), actual.get("sess01"));
|
||||
|
||||
this.registry.unregisterSubscription(unsubscribeMessage("sess01", "subs01"));
|
||||
actual = this.registry.findSubscriptions(message("/foo"));
|
||||
assertEquals("Expected 1 element", 1, actual.size());
|
||||
assertEquals(Arrays.asList("subs02"), actual.get("sess01"));
|
||||
|
||||
this.registry.unregisterSubscription(unsubscribeMessage("sess01", "subs02"));
|
||||
actual = this.registry.findSubscriptions(message("/foo"));
|
||||
assertEquals("Expected no element", 0, actual.size());
|
||||
|
||||
Reference in New Issue
Block a user