From 7fe8be1adccf66bed4c2ba5c3245927b6128d60c Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 7 Feb 2024 10:07:53 +0100 Subject: [PATCH] better work around for not processing race condition stanza --- .../conversations/xmpp/XmppConnection.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 25f210b12..9097a1256 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -1232,6 +1232,12 @@ public class XmppConnection implements Runnable { + "'"); return; } + if (Thread.currentThread().isInterrupted()) { + Log.d( + Config.LOGTAG, + account.getJid().asBareJid() + "Not processing iq. Thread was interrupted"); + return; + } if (packet instanceof JinglePacket jinglePacket && isBound) { if (this.jingleListener != null) { this.jingleListener.onJinglePacketReceived(account, jinglePacket); @@ -1308,11 +1314,18 @@ public class XmppConnection implements Runnable { + "'"); return; } + if (Thread.currentThread().isInterrupted()) { + Log.d( + Config.LOGTAG, + account.getJid().asBareJid() + + "Not processing message. Thread was interrupted"); + return; + } this.messageListener.onMessagePacketReceived(account, packet); } private void processPresence(final Tag currentTag) throws IOException { - PresencePacket packet = (PresencePacket) processPacket(currentTag, PACKET_PRESENCE); + final PresencePacket packet = (PresencePacket) processPacket(currentTag, PACKET_PRESENCE); if (!packet.valid()) { Log.e( Config.LOGTAG, @@ -1323,6 +1336,13 @@ public class XmppConnection implements Runnable { + "'"); return; } + if (Thread.currentThread().isInterrupted()) { + Log.d( + Config.LOGTAG, + account.getJid().asBareJid() + + "Not processing presence. Thread was interrupted"); + return; + } this.presenceListener.onPresencePacketReceived(account, packet); }