1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-21 01:57:57 +01:00

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.
This commit is contained in:
Florian Schmaus 2015-10-21 07:42:47 +02:00
parent 4f39c5b9c9
commit f5115f4666

View file

@ -1086,16 +1086,17 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
if (!smSessionId.equals(resumed.getPrevId())) { if (!smSessionId.equals(resumed.getPrevId())) {
throw new StreamIdDoesNotMatchException(smSessionId, 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 // First, drop the stanzas already handled by the server
processHandledCount(resumed.getHandledCount()); processHandledCount(resumed.getHandledCount());
// Then re-send what is left in the unacknowledged queue // Then re-send what is left in the unacknowledged queue
List<Stanza> stanzasToResend = new LinkedList<Stanza>(); List<Stanza> stanzasToResend = new ArrayList<>(unacknowledgedStanzas.size());
stanzasToResend.addAll(unacknowledgedStanzas); unacknowledgedStanzas.drainTo(stanzasToResend);
for (Stanza stanza : 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. // If there where stanzas resent, then request a SM ack for them.
// Writer's sendStreamElement() won't do it automatically based on // Writer's sendStreamElement() won't do it automatically based on
// predicates. // predicates.