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.