Commit 38b65e99 authored by Alex Wenckus's avatar Alex Wenckus Committed by alex

Syncronization. JM-605

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3622 b35dd754-fafc-0310-a699-88a17e54d16e
parent 4c59778b
...@@ -210,14 +210,16 @@ public class GroupManager { ...@@ -210,14 +210,16 @@ public class GroupManager {
* @return an unmodifiable Collection of all groups. * @return an unmodifiable Collection of all groups.
*/ */
public Collection<Group> getGroups() { public Collection<Group> getGroups() {
Collection<Group> groups = userGroupCache.get(globalGroupKey); synchronized (globalGroupKey) {
if (groups == null) { Collection<Group> groups = userGroupCache.get(globalGroupKey);
groups = provider.getGroups(); if (groups == null) {
// Add to cache and ensure correct identity groups = provider.getGroups();
groups = cacheAndEnsureIdentity(groups); // Add to cache and ensure correct identity
userGroupCache.put(globalGroupKey, groups); groups = cacheAndEnsureIdentity(groups);
userGroupCache.put(globalGroupKey, groups);
}
return groups;
} }
return groups;
} }
/** /**
...@@ -258,14 +260,17 @@ public class GroupManager { ...@@ -258,14 +260,17 @@ 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) {
Collection<Group> groups = userGroupCache.get(user); String userID = user.toString();
if (groups == null) { synchronized (userID.intern()) {
groups = provider.getGroups(user); Collection<Group> groups = userGroupCache.get(userID);
// Add to cache and ensure correct identity if (groups == null) {
groups = cacheAndEnsureIdentity(groups); groups = provider.getGroups(user);
userGroupCache.put(user.toString(), groups); // Add to cache and ensure correct identity
groups = cacheAndEnsureIdentity(groups);
userGroupCache.put(userID, groups);
}
return groups;
} }
return groups;
} }
/** /**
......
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