mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-23 13:07:59 +01:00
Allows to remove a connection listener while notifying that the connection is being closed. SMACK-162
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2386 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
31b508cc9f
commit
cd8f9f5682
1 changed files with 8 additions and 2 deletions
|
@ -202,8 +202,11 @@ class PacketReader {
|
|||
public void shutdown() {
|
||||
// Notify connection listeners of the connection closing if done hasn't already been set.
|
||||
if (!done) {
|
||||
ArrayList listenersCopy;
|
||||
synchronized (connectionListeners) {
|
||||
for (Iterator i=connectionListeners.iterator(); i.hasNext(); ) {
|
||||
// Make a copy since it's possible that a listener will be removed from the list
|
||||
listenersCopy = new ArrayList(connectionListeners);
|
||||
for (Iterator i=listenersCopy.iterator(); i.hasNext(); ) {
|
||||
ConnectionListener listener = (ConnectionListener)i.next();
|
||||
listener.connectionClosed();
|
||||
}
|
||||
|
@ -222,8 +225,11 @@ class PacketReader {
|
|||
done = true;
|
||||
connection.close();
|
||||
// Notify connection listeners of the error.
|
||||
ArrayList listenersCopy;
|
||||
synchronized (connectionListeners) {
|
||||
for (Iterator i=connectionListeners.iterator(); i.hasNext(); ) {
|
||||
// Make a copy since it's possible that a listener will be removed from the list
|
||||
listenersCopy = new ArrayList(connectionListeners);
|
||||
for (Iterator i=listenersCopy.iterator(); i.hasNext(); ) {
|
||||
ConnectionListener listener = (ConnectionListener)i.next();
|
||||
listener.connectionClosedOnError(e);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue