fixed concurrent modification when iterating over presences
This commit is contained in:
parent
8603d24bcb
commit
8edfc61346
|
@ -432,7 +432,7 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
|
|||
|
||||
public int activeDevicesWithRtpCapability() {
|
||||
int i = 0;
|
||||
for(Presence presence : getSelfContact().getPresences().getPresences().values()) {
|
||||
for(Presence presence : getSelfContact().getPresences().getPresences()) {
|
||||
if (RtpCapability.check(presence) != RtpCapability.Capability.NONE) {
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -11,8 +11,16 @@ import java.util.Map;
|
|||
public class Presences {
|
||||
private final Hashtable<String, Presence> presences = new Hashtable<>();
|
||||
|
||||
public Hashtable<String, Presence> getPresences() {
|
||||
return this.presences;
|
||||
public List<Presence> getPresences() {
|
||||
synchronized (this.presences) {
|
||||
return new ArrayList<>(this.presences.values());
|
||||
}
|
||||
}
|
||||
|
||||
public Presence get(String resource) {
|
||||
synchronized (this.presences) {
|
||||
return this.presences.get(resource);
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePresence(String resource, Presence presence) {
|
||||
|
|
|
@ -4468,8 +4468,8 @@ public class XmppConnectionService extends Service {
|
|||
}
|
||||
|
||||
private void injectServiceDiscoveryResult(Roster roster, String hash, String ver, ServiceDiscoveryResult disco) {
|
||||
for (Contact contact : roster.getContacts()) {
|
||||
for (Presence presence : contact.getPresences().getPresences().values()) {
|
||||
for (final Contact contact : roster.getContacts()) {
|
||||
for (final Presence presence : contact.getPresences().getPresences()) {
|
||||
if (hash.equals(presence.getHash()) && ver.equals(presence.getVer())) {
|
||||
presence.setServiceDiscoveryResult(disco);
|
||||
}
|
||||
|
|
|
@ -417,7 +417,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple
|
|||
final Jid jid = this.id.with;
|
||||
String resource = jid != null ? jid.getResource() : null;
|
||||
if (resource != null) {
|
||||
Presence presence = this.id.account.getRoster().getContact(jid).getPresences().getPresences().get(resource);
|
||||
Presence presence = this.id.account.getRoster().getContact(jid).getPresences().get(resource);
|
||||
ServiceDiscoveryResult result = presence != null ? presence.getServiceDiscoveryResult() : null;
|
||||
return result == null ? Collections.emptyList() : result.getFeatures();
|
||||
} else {
|
||||
|
|
|
@ -40,7 +40,7 @@ public class RtpCapability {
|
|||
public static Capability check(final Contact contact) {
|
||||
final Presences presences = contact.getPresences();
|
||||
Capability result = Capability.NONE;
|
||||
for(Presence presence : presences.getPresences().values()) {
|
||||
for(Presence presence : presences.getPresences()) {
|
||||
Capability capability = check(presence);
|
||||
if (capability == Capability.VIDEO) {
|
||||
result = capability;
|
||||
|
|
Loading…
Reference in a new issue