1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-10-31 17:25:58 +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() { final StanzaListener packetListener = new StanzaListener() {
@Override @Override
public void processStanza(Stanza packet) throws NotConnectedException, InterruptedException { 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 { try {
XMPPErrorException.ifHasErrorThenThrow(packet); XMPPErrorException.ifHasErrorThenThrow(packet);
callback.processStanza(packet); callback.processStanza(packet);