From 2aaedcb2fd07a0fb778a77375f1d16b6eff9f130 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 13 Jan 2015 11:21:47 +0100 Subject: [PATCH] Improve stanza ack listener handling - Don't abort if there is a NotConnectedExceptions, other listeners may want to be informed of the ack nevertheless. - Simply return if the id is null or empty. --- .../smack/tcp/XMPPTCPConnection.java | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) 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 268835164..d1b3ed0eb 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 @@ -1651,22 +1651,28 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { asyncGo(new Runnable() { @Override public void run() { - try { - for (Packet ackedStanza : ackedStanzas) { - for (PacketListener listener : stanzaAcknowledgedListeners) { + for (Packet ackedStanza : ackedStanzas) { + for (PacketListener listener : stanzaAcknowledgedListeners) { + try { listener.processPacket(ackedStanza); } - String id = ackedStanza.getPacketID(); - if (id != null) { - PacketListener listener = stanzaIdAcknowledgedListeners.remove(id); - if (listener != null) { - listener.processPacket(ackedStanza); - } + catch (NotConnectedException e) { + LOGGER.log(Level.FINER, "Received not connected exception", e); + } + } + String id = ackedStanza.getPacketID(); + if (StringUtils.isNotEmpty(id)) { + return; + } + PacketListener listener = stanzaIdAcknowledgedListeners.remove(id); + if (listener != null) { + try { + listener.processPacket(ackedStanza); + } + catch (NotConnectedException e) { + LOGGER.log(Level.FINER, "Received not connected exception", e); } } - } - catch (NotConnectedException e) { - LOGGER.log(Level.FINER, "Received not connected exception, aborting", e); } } });