Commit c99cafae authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Fixed NPE when trying to remove an item that does not exist. JM-392

git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@2798 b35dd754-fafc-0310-a699-88a17e54d16e
parent 6d4a7cfb
......@@ -329,7 +329,9 @@ public class Roster implements Cacheable {
throw new SharedGroupException("Cannot remove contact that belongs to a shared group");
}
if (itemToRemove != null) {
RosterItem.SubType subType = itemToRemove.getSubStatus();
// Cancel any existing presence subscription between the user and the contact
if (subType == RosterItem.SUB_TO || subType == RosterItem.SUB_BOTH) {
Presence presence = new Presence();
......@@ -338,6 +340,7 @@ public class Roster implements Cacheable {
presence.setType(Presence.Type.unsubscribe);
server.getPacketRouter().route(presence);
}
// cancel any existing presence subscription between the contact and the user
if (subType == RosterItem.SUB_FROM || subType == RosterItem.SUB_BOTH) {
Presence presence = new Presence();
......@@ -346,8 +349,10 @@ public class Roster implements Cacheable {
presence.setType(Presence.Type.unsubscribed);
server.getPacketRouter().route(presence);
}
// If removing the user was successful, remove the user from the subscriber list:
RosterItem item = rosterItems.remove(user.toBareJID());
if (item != null) {
// Delete the item from the provider if the item is persistent. RosteItems that only
// belong to shared groups won't be persistent
......@@ -362,8 +367,11 @@ public class Roster implements Cacheable {
roster.addItem(user, org.xmpp.packet.Roster.Subscription.remove);
broadcast(roster);
}
return item;
}
return 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