Commit 2905ee53 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Refactoring work.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3424 b35dd754-fafc-0310-a699-88a17e54d16e
parent 2b0ca427
...@@ -68,11 +68,16 @@ public class RosterManager extends BasicModule implements GroupEventListener { ...@@ -68,11 +68,16 @@ public class RosterManager extends BasicModule implements GroupEventListener {
throw new UserNotFoundException("Could not load caches"); throw new UserNotFoundException("Could not load caches");
} }
Roster roster = (Roster)rosterCache.get(username); Roster roster = (Roster)rosterCache.get(username);
if (roster == null) {
synchronized(username.intern()) {
roster = (Roster)rosterCache.get(username);
if (roster == null) { if (roster == null) {
// Not in cache so load a new one: // Not in cache so load a new one:
roster = new Roster(username); roster = new Roster(username);
rosterCache.put(username, roster); rosterCache.put(username, roster);
} }
}
}
if (roster == null) { if (roster == null) {
throw new UserNotFoundException(username); throw new UserNotFoundException(username);
} }
...@@ -93,11 +98,7 @@ public class RosterManager extends BasicModule implements GroupEventListener { ...@@ -93,11 +98,7 @@ public class RosterManager extends BasicModule implements GroupEventListener {
try { try {
String username = user.getNode(); String username = user.getNode();
// Get the roster of the deleted user // Get the roster of the deleted user
Roster roster = (Roster)CacheManager.getCache("username2roster").get(username); Roster roster = getRoster(username);
if (roster == null) {
// Not in cache so load a new one:
roster = new Roster(username);
}
// Remove each roster item from the user's roster // Remove each roster item from the user's roster
for (RosterItem item : roster.getRosterItems()) { for (RosterItem item : roster.getRosterItems()) {
try { try {
...@@ -115,24 +116,26 @@ public class RosterManager extends BasicModule implements GroupEventListener { ...@@ -115,24 +116,26 @@ public class RosterManager extends BasicModule implements GroupEventListener {
Iterator<String> usernames = rosteItemProvider.getUsernames(user.toBareJID()); Iterator<String> usernames = rosteItemProvider.getUsernames(user.toBareJID());
while (usernames.hasNext()) { while (usernames.hasNext()) {
username = usernames.next(); username = usernames.next();
try {
// Get the roster that has a reference to the deleted user // Get the roster that has a reference to the deleted user
roster = (Roster)CacheManager.getCache("username2roster").get(username); roster = getRoster(username);
if (roster == null) {
// Not in cache so load a new one:
roster = new Roster(username);
}
// Remove the deleted user reference from this roster // Remove the deleted user reference from this roster
try {
roster.deleteRosterItem(user, false); roster.deleteRosterItem(user, false);
} }
catch (SharedGroupException e) { catch (SharedGroupException e) {
// Do nothing. We shouldn't have this exception since we disabled the checkings // Do nothing. We shouldn't have this exception since we disabled the checkings
} }
catch (UserNotFoundException e) {
// Do nothing.
}
} }
} }
catch (UnsupportedOperationException e) { catch (UnsupportedOperationException e) {
// Do nothing // Do nothing
} }
catch (UserNotFoundException e) {
// Do nothing.
}
} }
/** /**
......
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