1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-25 15:52:06 +01:00

sendStanzaWithResponseCallback: Ensure exactly one callback is called

This commit is contained in:
Florian Schmaus 2017-01-30 21:01:56 +01:00
parent 46e8866440
commit 872b254db5

View file

@ -1494,7 +1494,12 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
final StanzaListener packetListener = new StanzaListener() {
@Override
public void processStanza(Stanza packet) throws NotConnectedException, InterruptedException {
removeAsyncStanzaListener(this);
boolean removed = removeAsyncStanzaListener(this);
if (!removed) {
// We lost a race against the "no response" handling runnable. Avoid calling the callback, as the
// exception callback will be invoked (if any).
return;
}
try {
XMPPErrorException.ifHasErrorThenThrow(packet);
callback.processStanza(packet);