fix stanza counting error after inline SM enable

This commit is contained in:
Daniel Gultsch 2024-03-10 17:38:56 +01:00
parent 5183a51625
commit e5cffa11be
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2

View file

@ -935,7 +935,8 @@ public class XmppConnection implements Runnable {
private void resetOutboundStanzaQueue() { private void resetOutboundStanzaQueue() {
synchronized (this.mStanzaQueue) { synchronized (this.mStanzaQueue) {
final List<AbstractAcknowledgeableStanza> intermediateStanzas = new ArrayList<>(); final ImmutableList.Builder<AbstractAcknowledgeableStanza> intermediateStanzasBuilder =
new ImmutableList.Builder<>();
if (Config.EXTENDED_SM_LOGGING) { if (Config.EXTENDED_SM_LOGGING) {
Log.d( Log.d(
Config.LOGTAG, Config.LOGTAG,
@ -946,12 +947,13 @@ public class XmppConnection implements Runnable {
for (int i = this.stanzasSentBeforeAuthentication + 1; i <= this.stanzasSent; ++i) { for (int i = this.stanzasSentBeforeAuthentication + 1; i <= this.stanzasSent; ++i) {
final AbstractAcknowledgeableStanza stanza = this.mStanzaQueue.get(i); final AbstractAcknowledgeableStanza stanza = this.mStanzaQueue.get(i);
if (stanza != null) { if (stanza != null) {
intermediateStanzas.add(stanza); intermediateStanzasBuilder.add(stanza);
} }
} }
this.mStanzaQueue.clear(); this.mStanzaQueue.clear();
final var intermediateStanzas = intermediateStanzasBuilder.build();
for (int i = 0; i < intermediateStanzas.size(); ++i) { for (int i = 0; i < intermediateStanzas.size(); ++i) {
this.mStanzaQueue.put(i, intermediateStanzas.get(i)); this.mStanzaQueue.append(i + 1, intermediateStanzas.get(i));
} }
this.stanzasSent = intermediateStanzas.size(); this.stanzasSent = intermediateStanzas.size();
if (Config.EXTENDED_SM_LOGGING) { if (Config.EXTENDED_SM_LOGGING) {