From ca9c6aea93d4471a0a946a7a157427d053d3f23c Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Tue, 23 Aug 2005 00:01:04 +0000 Subject: [PATCH] Add/remove the local entry to/from only if the server didn't answer an error to the request. SMACK-73 git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2707 b35dd754-fafc-0310-a699-88a17e54d16e --- source/org/jivesoftware/smack/RosterGroup.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/org/jivesoftware/smack/RosterGroup.java b/source/org/jivesoftware/smack/RosterGroup.java index 4c65b562a..7f653bc96 100644 --- a/source/org/jivesoftware/smack/RosterGroup.java +++ b/source/org/jivesoftware/smack/RosterGroup.java @@ -178,7 +178,6 @@ public class RosterGroup { // Only add the entry if it isn't already in the list. synchronized (entries) { if (!entries.contains(entry)) { - entries.add(entry); RosterPacket packet = new RosterPacket(); packet.setType(IQ.Type.SET); packet.addRosterItem(RosterEntry.toRosterItem(entry)); @@ -198,6 +197,8 @@ public class RosterGroup { else if (response.getType() == IQ.Type.ERROR) { throw new XMPPException(response.getError()); } + // Add the new entry to the group since the server processed the request successfully + entries.add(entry); } } @@ -226,8 +227,6 @@ public class RosterGroup { collector = connection .createPacketCollector(new PacketIDFilter(packet.getPacketID())); connection.sendPacket(packet); - // Remove the entry locally - entries.remove(entry); } } if (collector != null) { @@ -240,6 +239,8 @@ public class RosterGroup { else if (response.getType() == IQ.Type.ERROR) { throw new XMPPException(response.getError()); } + // Remove the entry locally since the server processed the request successfully + entries.remove(entry); } }