1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-06-14 23:54:49 +02:00

Use Async.go() in OMEMO PEPListener

to avoid a deadlock, since the PEP listener is synchronous.
This commit is contained in:
Florian Schmaus 2017-09-29 15:43:29 +02:00
parent 58181bab08
commit c70a1921db

View file

@ -814,17 +814,24 @@ public final class OmemoManager extends Manager {
Set<Integer> deviceListIds = omemoDeviceListElement.copyDeviceIds();
//enroll at the deviceList
deviceListIds.add(ourDeviceId);
omemoDeviceListElement = new OmemoDeviceListVAxolotlElement(deviceListIds);
final OmemoDeviceListVAxolotlElement newOmemoDeviceListElement = new OmemoDeviceListVAxolotlElement(deviceListIds);
// PEPListener is a synchronous listener. Avoid any deadlocks by using an async task to update the device list.
Async.go(new Runnable() {
@Override
public void run() {
try {
OmemoService.publishDeviceIds(OmemoManager.this, omemoDeviceListElement);
} catch (SmackException | InterruptedException | XMPPException.XMPPErrorException e) {
OmemoService.publishDeviceIds(OmemoManager.this, newOmemoDeviceListElement);
}
catch (SmackException | InterruptedException | XMPPException.XMPPErrorException e) {
// TODO: It might be dangerous NOT to retry publishing our deviceId
LOGGER.log(Level.SEVERE,
"Could not publish our device list after an update without our id was received: "
+ e.getMessage());
}
}
});
}
}
}
};