From 45d3ee7ccaceaf860aaeb68b077c96d12c912e72 Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Thu, 29 Sep 2022 12:18:43 -0500 Subject: [PATCH] fix: Fix ConcurrentModificationException when bridge count changes. --- .../jicofo/bridge/colibri/Colibri2Session.kt | 1 - .../conference/JitsiMeetConferenceImpl.java | 26 +++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/jicofo-selector/src/main/kotlin/org/jitsi/jicofo/bridge/colibri/Colibri2Session.kt b/jicofo-selector/src/main/kotlin/org/jitsi/jicofo/bridge/colibri/Colibri2Session.kt index 4c8c344660..4cb2a90e80 100644 --- a/jicofo-selector/src/main/kotlin/org/jitsi/jicofo/bridge/colibri/Colibri2Session.kt +++ b/jicofo-selector/src/main/kotlin/org/jitsi/jicofo/bridge/colibri/Colibri2Session.kt @@ -25,7 +25,6 @@ import org.jitsi.utils.OrderedJsonObject import org.jitsi.utils.logging2.Logger import org.jitsi.utils.logging2.createChildLogger import org.jitsi.xmpp.extensions.colibri.WebSocketPacketExtension -import org.jitsi.xmpp.extensions.colibri2.Capability import org.jitsi.xmpp.extensions.colibri2.Colibri2Endpoint import org.jitsi.xmpp.extensions.colibri2.Colibri2Relay import org.jitsi.xmpp.extensions.colibri2.ConferenceModifiedIQ diff --git a/jicofo/src/main/java/org/jitsi/jicofo/conference/JitsiMeetConferenceImpl.java b/jicofo/src/main/java/org/jitsi/jicofo/conference/JitsiMeetConferenceImpl.java index 54b67b0b1a..fa2f377df4 100644 --- a/jicofo/src/main/java/org/jitsi/jicofo/conference/JitsiMeetConferenceImpl.java +++ b/jicofo/src/main/java/org/jitsi/jicofo/conference/JitsiMeetConferenceImpl.java @@ -187,7 +187,7 @@ public class JitsiMeetConferenceImpl /** * The conference properties that we advertise in presence in the XMPP MUC. */ - private final ConferenceProperties conferenceProperties = new ConferenceProperties(); + private final ConcurrentHashMap conferenceProperties = new ConcurrentHashMap<>(); /** * See {@link JitsiMeetConference#includeInStatistics()} @@ -512,7 +512,7 @@ else if (ConferenceConfig.config.enableAutoOwner()) Boolean.TRUE.toString(), false); - presenceExtensions.add(ConferenceProperties.clone(conferenceProperties)); + presenceExtensions.add(createConferenceProperties()); // updates presence with presenceExtensions and sends it chatRoom.modifyPresence(null, presenceExtensions); @@ -524,7 +524,7 @@ else if (ConferenceConfig.config.enableAutoOwner()) * @param key the key of the property. * @param value the value of the property. */ - private void setConferenceProperty(String key, String value) + private void setConferenceProperty(@NotNull String key, @NotNull String value) { setConferenceProperty(key, value, true); } @@ -539,15 +539,22 @@ private void setConferenceProperty(String key, String value) * and {@code false} to only add the property locally. This is useful to * allow updating multiple properties but sending a single presence update. */ - private void setConferenceProperty(String key, String value, boolean updatePresence) + private void setConferenceProperty(@NotNull String key, @NotNull String value, boolean updatePresence) { - conferenceProperties.put(key, value); - if (updatePresence && chatRoom != null) + String oldValue = conferenceProperties.put(key, value); + if (updatePresence && chatRoom != null && !value.equals(oldValue)) { - chatRoom.setPresenceExtension(ConferenceProperties.clone(conferenceProperties), false); + chatRoom.setPresenceExtension(createConferenceProperties(), false); } } + private ConferenceProperties createConferenceProperties() + { + ConferenceProperties conferenceProperties = new ConferenceProperties(); + this.conferenceProperties.forEach(conferenceProperties::put); + return conferenceProperties; + } + /** * Process the new number of audio senders reported by the chat room. */ @@ -1564,10 +1571,7 @@ public OrderedJsonObject getDebugState() o.put("colibri_session_manager", colibriSessionManager.getDebugState()); } OrderedJsonObject conferencePropertiesJson = new OrderedJsonObject(); - for (ConferenceProperties.ConferenceProperty conferenceProperty : conferenceProperties.getProperties()) - { - conferencePropertiesJson.put(conferenceProperty.getKey(), conferenceProperty.getValue()); - } + conferenceProperties.forEach(conferencePropertiesJson::put); o.put("conference_properties", conferencePropertiesJson); o.put("include_in_statistics", includeInStatistics); o.put("conference_sources", conferenceSources.toJson());