1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-10 18:59:41 +02:00

Switched from volatile collection to copy on write array. Fixes concurrency bugs and leaking resources, but may have performance ramifications.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7159 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2007-02-16 00:12:17 +00:00 committed by matt
parent 4cfbf00e48
commit 7c847dad6a
3 changed files with 41 additions and 175 deletions

View file

@ -184,13 +184,8 @@ public class ReconnectionManager implements ConnectionListener {
protected void notifyReconnectionFailed(Exception exception) {
List<ConnectionListener> listenersCopy;
if (isReconnectionAllowed()) {
synchronized (connection.packetReader.connectionListeners) {
// Makes a copy since it's possible that a listener will be removed from the list
listenersCopy = new ArrayList<ConnectionListener>(
connection.packetReader.connectionListeners);
for (ConnectionListener listener : listenersCopy) {
listener.reconnectionFailed(exception);
}
for (ConnectionListener listener : connection.packetReader.connectionListeners) {
listener.reconnectionFailed(exception);
}
}
}
@ -201,15 +196,9 @@ public class ReconnectionManager implements ConnectionListener {
* @param seconds the number of seconds that a reconnection will be attempted in.
*/
protected void notifyAttemptToReconnectIn(int seconds) {
List<ConnectionListener> listenersCopy;
if (isReconnectionAllowed()) {
synchronized (connection.packetReader.connectionListeners) {
// Makes a copy since it's possible that a listener will be removed from the list
listenersCopy = new ArrayList<ConnectionListener>(
connection.packetReader.connectionListeners);
for (ConnectionListener listener : listenersCopy) {
listener.reconnectingIn(seconds);
}
for (ConnectionListener listener : connection.packetReader.connectionListeners) {
listener.reconnectingIn(seconds);
}
}
}