mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-23 11:07:57 +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() {
|
public void shutdown() {
|
||||||
// Notify connection listeners of the connection closing if done hasn't already been set.
|
// Notify connection listeners of the connection closing if done hasn't already been set.
|
||||||
if (!done) {
|
if (!done) {
|
||||||
|
ArrayList listenersCopy;
|
||||||
synchronized (connectionListeners) {
|
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();
|
ConnectionListener listener = (ConnectionListener)i.next();
|
||||||
listener.connectionClosed();
|
listener.connectionClosed();
|
||||||
}
|
}
|
||||||
|
@ -222,8 +225,11 @@ class PacketReader {
|
||||||
done = true;
|
done = true;
|
||||||
connection.close();
|
connection.close();
|
||||||
// Notify connection listeners of the error.
|
// Notify connection listeners of the error.
|
||||||
|
ArrayList listenersCopy;
|
||||||
synchronized (connectionListeners) {
|
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();
|
ConnectionListener listener = (ConnectionListener)i.next();
|
||||||
listener.connectionClosedOnError(e);
|
listener.connectionClosedOnError(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue