From 5e203086b3a9549719d983613449c029abb004d8 Mon Sep 17 00:00:00 2001 From: Guus der Kinderen Date: Fri, 25 Jun 2021 15:54:10 +0200 Subject: [PATCH] [sint] increase stability Some roster-based tests depend on there not being any prior subscription state beteween entities. The utility method that tries to guarantee that, acts on the state of the roster that's cached in memory, but acts on the one that's stored on the server. This occasionally causes issues, as both representations might be different. Stability is added in this commit by: - refreshing the roster from the server prior to evaluating it - ignoring an 'item-not-found' as returned by the server, when the code tries to remove that item. --- .../inttest/util/IntegrationTestRosterUtil.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/util/IntegrationTestRosterUtil.java b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/util/IntegrationTestRosterUtil.java index c03ba1850..4a6569dcf 100644 --- a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/util/IntegrationTestRosterUtil.java +++ b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/util/IntegrationTestRosterUtil.java @@ -24,6 +24,7 @@ import org.jivesoftware.smack.SmackException.NotLoggedInException; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.packet.Presence; +import org.jivesoftware.smack.packet.StanzaError; import org.jivesoftware.smack.roster.AbstractPresenceEventListener; import org.jivesoftware.smack.roster.PresenceEventListener; import org.jivesoftware.smack.roster.Roster; @@ -99,7 +100,16 @@ public class IntegrationTestRosterUtil { if (c2Entry == null) { return; } - roster.removeEntry(c2Entry); + try { + roster.removeEntry(c2Entry); + } catch (XMPPErrorException e) { + // Account for race conditions: server-sided, the item might already have been removed. + if (e.getStanzaError().getCondition() == StanzaError.Condition.item_not_found) { + // Trying to remove non-existing item. As it needs to be gone, this is fine. + return; + } + throw e; + } } }