Commit 1da2506b authored by Dave Cridland's avatar Dave Cridland Committed by GitHub

Merge pull request #713 from akrherz/of867

OF-867 Wrong key in groupMetaCache evict
parents 7aaf1b0f 508e39e2
...@@ -174,9 +174,7 @@ public class GroupManager { ...@@ -174,9 +174,7 @@ public class GroupManager {
// Remove only the collection of groups the member belongs to. // Remove only the collection of groups the member belongs to.
String member = (String) params.get("member"); String member = (String) params.get("member");
if(member != null) { evictCachedUserForGroup(member);
groupMetaCache.remove(member);
}
} }
@Override @Override
...@@ -187,9 +185,7 @@ public class GroupManager { ...@@ -187,9 +185,7 @@ public class GroupManager {
// Remove only the collection of groups the member belongs to. // Remove only the collection of groups the member belongs to.
String member = (String) params.get("member"); String member = (String) params.get("member");
if(member != null) { evictCachedUserForGroup(member);
groupMetaCache.remove(member);
}
} }
@Override @Override
...@@ -200,9 +196,7 @@ public class GroupManager { ...@@ -200,9 +196,7 @@ public class GroupManager {
// Remove only the collection of groups the member belongs to. // Remove only the collection of groups the member belongs to.
String member = (String) params.get("admin"); String member = (String) params.get("admin");
if(member != null) { evictCachedUserForGroup(member);
groupMetaCache.remove(member);
}
} }
@Override @Override
...@@ -213,11 +207,20 @@ public class GroupManager { ...@@ -213,11 +207,20 @@ public class GroupManager {
// Remove only the collection of groups the member belongs to. // Remove only the collection of groups the member belongs to.
String member = (String) params.get("admin"); String member = (String) params.get("admin");
if(member != null) { evictCachedUserForGroup(member);
groupMetaCache.remove(member);
}
} }
private void evictCachedUserForGroup(String user) {
if(user != null) {
JID userJid = new JID(user);
if (XMPPServer.getInstance().isLocal(userJid)) {
String username = userJid.getNode();
synchronized ((getClass().getSimpleName() + username).intern()) {
groupMetaCache.remove(username);
}
}
}
}
}); });
UserEventDispatcher.addListener(new UserEventListener() { UserEventDispatcher.addListener(new UserEventListener() {
...@@ -477,7 +480,7 @@ public class GroupManager { ...@@ -477,7 +480,7 @@ public class GroupManager {
public Collection<Group> getSharedGroups(String userName) { public Collection<Group> getSharedGroups(String userName) {
Collection<String> groupNames = (Collection<String>)groupMetaCache.get(userName); Collection<String> groupNames = (Collection<String>)groupMetaCache.get(userName);
if (groupNames == null) { if (groupNames == null) {
synchronized(userName.intern()) { synchronized((getClass().getSimpleName() + userName).intern()) {
groupNames = (Collection<String>)groupMetaCache.get(userName); groupNames = (Collection<String>)groupMetaCache.get(userName);
if (groupNames == null) { if (groupNames == null) {
// assume this is a local user // assume this is a local user
...@@ -586,7 +589,7 @@ public class GroupManager { ...@@ -586,7 +589,7 @@ public class GroupManager {
* @return all groups that an entity belongs to. * @return all groups that an entity belongs to.
*/ */
public Collection<Group> getGroups(JID user) { public Collection<Group> getGroups(JID user) {
String key = user.toBareJID(); String key = user.getNode();
Collection<String> groupNames = (Collection<String>)groupMetaCache.get(key); Collection<String> groupNames = (Collection<String>)groupMetaCache.get(key);
if (groupNames == null) { if (groupNames == null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment