mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-29 07:22:07 +01: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:
parent
fa643f12d5
commit
e2e228fc93
1 changed files with 8 additions and 4 deletions
|
@ -420,10 +420,14 @@ public class MUCUser implements ExtensionElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Status create(Integer i) {
|
public static Status create(Integer i) {
|
||||||
Status status = statusMap.get(i);
|
Status status;
|
||||||
if (status == null) {
|
// TODO: Use computeIfAbsent once Smack's minimum required Android SDK level is 24 or higher.
|
||||||
status = new Status(i);
|
synchronized (statusMap) {
|
||||||
statusMap.put(i, status);
|
status = statusMap.get(i);
|
||||||
|
if (status == null) {
|
||||||
|
status = new Status(i);
|
||||||
|
statusMap.put(i, status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue