From b142060f9e165e74bd6633bb5f73b857f2ac94bc Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 30 Jan 2017 16:57:43 +0100 Subject: [PATCH] sendStanzaWithResponseCallback(): remove listener right away I'm not sure why i've put the removeAsyncStanzaListener() call into the finally block. If callback.processStanza(Stanza) takes a long time (or even blocks), then it would appear to the "no response" handling Runnable as if there was no response, when in fact there was one. --- .../java/org/jivesoftware/smack/AbstractXMPPConnection.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index b75e937a5..bdfa066a2 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -1494,6 +1494,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { final StanzaListener packetListener = new StanzaListener() { @Override public void processStanza(Stanza packet) throws NotConnectedException, InterruptedException { + removeAsyncStanzaListener(this); try { XMPPErrorException.ifHasErrorThenThrow(packet); callback.processStanza(packet); @@ -1503,9 +1504,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { exceptionCallback.processException(e); } } - finally { - removeAsyncStanzaListener(this); - } } }; removeCallbacksService.schedule(new Runnable() {