mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 06:12:05 +01:00
sendStanzaWithResponseCallback: Ensure exactly one callback is called
This commit is contained in:
parent
46e8866440
commit
872b254db5
1 changed files with 6 additions and 1 deletions
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue