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

muc: synchronize Stats.create(Integer)

Since this method is used by the MUCUserProvider, it is potentially
invoked concurrently and the access to the statusMap must be
synchronized then.
This commit is contained in:
Florian Schmaus 2020-04-16 21:20:53 +02:00
parent fa643f12d5
commit e2e228fc93

View file

@ -420,11 +420,15 @@ public class MUCUser implements ExtensionElement {
} }
public static Status create(Integer i) { public static Status create(Integer i) {
Status status = statusMap.get(i); Status status;
// TODO: Use computeIfAbsent once Smack's minimum required Android SDK level is 24 or higher.
synchronized (statusMap) {
status = statusMap.get(i);
if (status == null) { if (status == null) {
status = new Status(i); status = new Status(i);
statusMap.put(i, status); statusMap.put(i, status);
} }
}
return status; return status;
} }