1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 22:32:06 +01:00

Use CopyOnWriteArraySet for connectionListener

This commit is contained in:
Florian Schmaus 2014-10-09 23:55:02 +02:00
parent 6dcba44557
commit 03686fbaaf

View file

@ -22,9 +22,11 @@ import java.io.Writer;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadFactory;
@ -93,8 +95,8 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* A collection of ConnectionListeners which listen for connection closing * A collection of ConnectionListeners which listen for connection closing
* and reconnection events. * and reconnection events.
*/ */
protected final Collection<ConnectionListener> connectionListeners = protected final Set<ConnectionListener> connectionListeners =
new CopyOnWriteArrayList<ConnectionListener>(); new CopyOnWriteArraySet<ConnectionListener>();
/** /**
* A collection of PacketCollectors which collects packets for a specified filter * A collection of PacketCollectors which collects packets for a specified filter
@ -609,10 +611,8 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
if (connectionListener == null) { if (connectionListener == null) {
return; return;
} }
if (!connectionListeners.contains(connectionListener)) {
connectionListeners.add(connectionListener); connectionListeners.add(connectionListener);
} }
}
@Override @Override
public void removeConnectionListener(ConnectionListener connectionListener) { public void removeConnectionListener(ConnectionListener connectionListener) {