mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 01:29:38 +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:
parent
4cfbf00e48
commit
7c847dad6a
3 changed files with 41 additions and 175 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue