Commit 787a8023 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Fixed concurrency problem.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@748 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1213aab0
...@@ -38,7 +38,7 @@ public class UserManager { ...@@ -38,7 +38,7 @@ public class UserManager {
CacheManager.initializeCache("userCache", 512 * 1024); CacheManager.initializeCache("userCache", 512 * 1024);
CacheManager.initializeCache("username2roster", 512 * 1024); CacheManager.initializeCache("username2roster", 512 * 1024);
userCache = CacheManager.getCache("userCache"); userCache = CacheManager.getCache("userCache");
// Load a group provider. // Load a user provider.
String className = JiveGlobals.getXMLProperty("provider.user.className", String className = JiveGlobals.getXMLProperty("provider.user.className",
"org.jivesoftware.messenger.user.DefaultUserProvider"); "org.jivesoftware.messenger.user.DefaultUserProvider");
try { try {
...@@ -130,10 +130,15 @@ public class UserManager { ...@@ -130,10 +130,15 @@ public class UserManager {
catch (StringprepException se) { catch (StringprepException se) {
throw new IllegalArgumentException(se); throw new IllegalArgumentException(se);
} }
User user = (User)userCache.get(username); User user = (User) userCache.get(username);
if (user == null) { if (user == null) {
user = provider.loadUser(username); synchronized(username.intern()) {
userCache.put(username, user); user = (User) userCache.get(username);
if (user == null) {
user = provider.loadUser(username);
userCache.put(username, user);
}
}
} }
return user; return user;
} }
......
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