Skip to content

Commit

Permalink
Fix concurrency issues with voice- and thread members
Browse files Browse the repository at this point in the history
  • Loading branch information
wasdennnoch committed Jun 23, 2024
1 parent d666889 commit 3e27ba4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;

/**
* The implementation of {@link ServerThreadChannel}.
Expand Down Expand Up @@ -94,7 +95,7 @@ public ServerThreadChannelImpl(final DiscordApiImpl api, final ServerImpl server
lastMessageId = data.hasNonNull("last_message_id") ? data.get("last_message_id").asLong() : 0;
rateLimitPerUser = data.get("rate_limit_per_user").asInt(0);

members = new HashSet<>();
members = ConcurrentHashMap.newKeySet();
if (data.hasNonNull("member")) {
// If userId is not included, that means this came from a GUILD_CREATE event
// This means the userId is the bot's and the thread id is from this thread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import org.javacord.core.listener.channel.server.voice.InternalServerVoiceChannelAttachableListenerManager;

import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

/**
Expand All @@ -37,7 +37,7 @@ public class ServerVoiceChannelImpl extends TextableRegularServerChannelImpl
/**
* The ids of the connected users of this server voice channel.
*/
private final Set<Long> connectedUsers = new HashSet<>();
private final Set<Long> connectedUsers = ConcurrentHashMap.newKeySet();

/**
* Creates a new server voice channel object.
Expand Down

0 comments on commit 3e27ba4

Please sign in to comment.