Skip to content

Commit

Permalink
fix: Fix ConcurrentModificationException when bridge count changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrozev committed Sep 29, 2022
1 parent 20b9311 commit 45d3ee7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> conferenceProperties = new ConcurrentHashMap<>();

/**
* See {@link JitsiMeetConference#includeInStatistics()}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand All @@ -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.
*/
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 45d3ee7

Please sign in to comment.