From 03dc15158b47ea0ed00da0964826ee80dba77412 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 9 Feb 2024 11:23:05 +0100 Subject: [PATCH] use modern Java in XmppConnection --- .../conversations/xmpp/XmppConnection.java | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 69fad55e8..ef065c59d 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -1162,8 +1162,7 @@ public class XmppConnection implements Runnable { + mStanzaQueue.keyAt(i)); } final AbstractAcknowledgeableStanza stanza = mStanzaQueue.valueAt(i); - if (stanza instanceof MessagePacket && acknowledgedListener != null) { - final MessagePacket packet = (MessagePacket) stanza; + if (stanza instanceof MessagePacket packet && acknowledgedListener != null) { final String id = packet.getId(); final Jid to = packet.getTo(); if (id != null && to != null) { @@ -1846,8 +1845,10 @@ public class XmppConnection implements Runnable { resetAttemptCount(true); resetStreamId(); clearIqCallbacks(); - this.stanzasSent = 0; - mStanzaQueue.clear(); + synchronized (this.mStanzaQueue) { + this.stanzasSent = 0; + this.mStanzaQueue.clear(); + } this.redirectionUrl = null; synchronized (this.disco) { disco.clear(); @@ -2332,8 +2333,7 @@ public class XmppConnection implements Runnable { synchronized (this.mStanzaQueue) { for (int i = 0; i < mStanzaQueue.size(); ++i) { final AbstractAcknowledgeableStanza stanza = mStanzaQueue.valueAt(i); - if (stanza instanceof MessagePacket) { - final MessagePacket packet = (MessagePacket) stanza; + if (stanza instanceof MessagePacket packet) { final String id = packet.getId(); final Jid to = packet.getTo(); mXmppConnectionService.markMessage( @@ -2458,9 +2458,7 @@ public class XmppConnection implements Runnable { + " do not write stanza to unbound stream " + packet.toString()); } - if (packet instanceof AbstractAcknowledgeableStanza) { - AbstractAcknowledgeableStanza stanza = (AbstractAcknowledgeableStanza) packet; - + if (packet instanceof AbstractAcknowledgeableStanza stanza) { if (this.mStanzaQueue.size() != 0) { int currentHighestKey = this.mStanzaQueue.keyAt(this.mStanzaQueue.size() - 1); if (currentHighestKey != stanzasSent) { @@ -2860,11 +2858,6 @@ public class XmppConnection implements Runnable { && pepPublishOptions(); } - public boolean avatarConversion() { - return hasDiscoFeature(account.getJid().asBareJid(), Namespace.AVATAR_CONVERSION) - && pepPublishOptions(); - } - public boolean blocking() { return hasDiscoFeature(account.getDomain(), Namespace.BLOCKING); }