Skip to content

Commit

Permalink
Add missing cache cleanup for news/stage/thread channels (#2029)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitmocc committed Feb 19, 2022
1 parent a77218c commit e328d17
Showing 1 changed file with 19 additions and 0 deletions.
Expand Up @@ -64,11 +64,20 @@ protected Long handleInternally(DataObject content)
//Remove everything from global cache
// this prevents some race-conditions for getting audio managers from guilds
SnowflakeCacheViewImpl<Guild> guildView = getJDA().getGuildsView();
SnowflakeCacheViewImpl<StageChannel> stageView = getJDA().getStageChannelView();
SnowflakeCacheViewImpl<StoreChannel> storeView = getJDA().getStoreChannelsView();
SnowflakeCacheViewImpl<TextChannel> textView = getJDA().getTextChannelsView();
SnowflakeCacheViewImpl<ThreadChannel> threadView = getJDA().getThreadChannelsView();
SnowflakeCacheViewImpl<NewsChannel> newsView = getJDA().getNewsChannelView();
SnowflakeCacheViewImpl<VoiceChannel> voiceView = getJDA().getVoiceChannelsView();
SnowflakeCacheViewImpl<Category> categoryView = getJDA().getCategoriesView();

guildView.remove(id);
try (UnlockHook hook = stageView.writeLock())
{
guild.getStageChannelCache()
.forEachUnordered(chan -> stageView.getMap().remove(chan.getIdLong()));
}
try (UnlockHook hook = storeView.writeLock())
{
guild.getStoreChannelCache()
Expand All @@ -79,6 +88,16 @@ protected Long handleInternally(DataObject content)
guild.getTextChannelCache()
.forEachUnordered(chan -> textView.getMap().remove(chan.getIdLong()));
}
try (UnlockHook hook = threadView.writeLock())
{
guild.getThreadChannelsView()
.forEachUnordered(chan -> threadView.getMap().remove(chan.getIdLong()));
}
try (UnlockHook hook = newsView.writeLock())
{
guild.getNewsChannelCache()
.forEachUnordered(chan -> newsView.getMap().remove(chan.getIdLong()));
}
try (UnlockHook hook = voiceView.writeLock())
{
guild.getVoiceChannelCache()
Expand Down

0 comments on commit e328d17

Please sign in to comment.