Skip to content

Commit

Permalink
Fix ConcurrentModificationException when shutting down async listeners (
Browse files Browse the repository at this point in the history
  • Loading branch information
SzczurekYT authored Sep 23, 2024
1 parent 3cb261f commit d636be8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main/java/com/comphenix/protocol/async/AsyncFilterManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@

package com.comphenix.protocol.async;

import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;

import com.comphenix.protocol.AsynchronousManager;
import com.comphenix.protocol.PacketStream;
import com.comphenix.protocol.PacketType;
Expand All @@ -37,8 +29,16 @@
import com.comphenix.protocol.injector.collection.OutboundPacketListenerSet;
import com.comphenix.protocol.scheduler.ProtocolScheduler;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;

import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

/**
* Represents a filter manager for asynchronous packets.
Expand Down Expand Up @@ -284,9 +284,9 @@ public void unregisterAsyncHandlers(Plugin plugin) {
}

private void unregisterAsyncHandlers(PacketProcessingQueue processingQueue, Plugin plugin) {

// Iterate through every packet listener
for (AsyncListenerHandler listener : processingQueue.values()) {
for (AsyncListenerHandler listener : ImmutableList.copyOf(processingQueue.values())) {
// Remove the listener
if (Objects.equal(listener.getPlugin(), plugin)) {
unregisterAsyncHandler(listener);
Expand Down

0 comments on commit d636be8

Please sign in to comment.