From f5115f46669e2d17fab080f490e0be0e390c4597 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 21 Oct 2015 07:42:47 +0200 Subject: [PATCH] Empty unacknowledgedStanzas when 'resumed' is received by changing stanzasToResend.addAll(unacknowledgedStanzas); to unacknowledgedStanzas.drainTo(stanzasToResend); Also use sendStanzaInternal to call the callbacks, which also requires the smEnabledSyncPoint to got signaled. Fixes SMACK-700. Thanks to Juan Antonio for reporting this. --- .../org/jivesoftware/smack/tcp/XMPPTCPConnection.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index bd179028a..28070cdfc 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -1086,16 +1086,17 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { if (!smSessionId.equals(resumed.getPrevId())) { throw new StreamIdDoesNotMatchException(smSessionId, resumed.getPrevId()); } + // Mark SM as enabled and resumption as successful. + smResumedSyncPoint.reportSuccess(); + smEnabledSyncPoint.reportSuccess(); // First, drop the stanzas already handled by the server processHandledCount(resumed.getHandledCount()); // Then re-send what is left in the unacknowledged queue - List stanzasToResend = new LinkedList(); - stanzasToResend.addAll(unacknowledgedStanzas); + List stanzasToResend = new ArrayList<>(unacknowledgedStanzas.size()); + unacknowledgedStanzas.drainTo(stanzasToResend); for (Stanza stanza : stanzasToResend) { - packetWriter.sendStreamElement(stanza); + sendStanzaInternal(stanza); } - smResumedSyncPoint.reportSuccess(); - smEnabledSyncPoint.reportSuccess(); // If there where stanzas resent, then request a SM ack for them. // Writer's sendStreamElement() won't do it automatically based on // predicates.