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 {
* @return an unmodifiable Collection of all groups.
*/
public Collection<Group> getGroups() {
Collection<Group> groups = userGroupCache.get(globalGroupKey);
if (groups == null) {
groups = provider.getGroups();
// Add to cache and ensure correct identity
groups = cacheAndEnsureIdentity(groups);
userGroupCache.put(globalGroupKey, groups);
synchronized (globalGroupKey) {
Collection<Group> groups = userGroupCache.get(globalGroupKey);
if (groups == null) {
groups = provider.getGroups();
// Add to cache and ensure correct identity
groups = cacheAndEnsureIdentity(groups);
userGroupCache.put(globalGroupKey, groups);
}
return groups;
}
return groups;
}
/**
......@@ -258,14 +260,17 @@ public class GroupManager {
* @return all groups that an entity belongs to.
*/
public Collection<Group> getGroups(JID user) {
Collection<Group> groups = userGroupCache.get(user);
if (groups == null) {
groups = provider.getGroups(user);
// Add to cache and ensure correct identity
groups = cacheAndEnsureIdentity(groups);
userGroupCache.put(user.toString(), groups);
String userID = user.toString();
synchronized (userID.intern()) {
Collection<Group> groups = userGroupCache.get(userID);
if (groups == null) {
groups = provider.getGroups(user);
// 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