mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-16 12:12:06 +01:00
1) Use #notifyAll to notify all waiting threads on listenethread. SMACK-189
2) Added try/catch while notifying listener to recover gracefully from potential errors. SMACK-190 git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7043 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
85dcb0a5c4
commit
2db477145d
1 changed files with 27 additions and 6 deletions
|
@ -185,15 +185,22 @@ class PacketReader {
|
|||
// Make a copy since it's possible that a listener will be removed from the list
|
||||
listenersCopy = new ArrayList<ConnectionListener>(connectionListeners);
|
||||
for (ConnectionListener listener : listenersCopy) {
|
||||
try {
|
||||
listener.connectionClosed();
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Cath and print any exception so we can recover
|
||||
// from a faulty listener and finish the shutdown process
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
done = true;
|
||||
|
||||
// Make sure that the listenerThread is awake to shutdown properly
|
||||
synchronized (listenerThread) {
|
||||
listenerThread.notify();
|
||||
listenerThread.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,13 +222,20 @@ class PacketReader {
|
|||
// Make a copy since it's possible that a listener will be removed from the list
|
||||
listenersCopy = new ArrayList<ConnectionListener>(connectionListeners);
|
||||
for (ConnectionListener listener : listenersCopy) {
|
||||
try {
|
||||
listener.connectionClosedOnError(e);
|
||||
}
|
||||
catch (Exception e2) {
|
||||
// Cath and print any exception so we can recover
|
||||
// from a faulty listener
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure that the listenerThread is awake to shutdown properly
|
||||
synchronized (listenerThread) {
|
||||
listenerThread.notify();
|
||||
listenerThread.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,13 +249,20 @@ class PacketReader {
|
|||
// Make a copy since it's possible that a listener will be removed from the list
|
||||
listenersCopy = new ArrayList<ConnectionListener>(connectionListeners);
|
||||
for (ConnectionListener listener : listenersCopy) {
|
||||
try {
|
||||
listener.reconnectionSuccessful();
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Cath and print any exception so we can recover
|
||||
// from a faulty listener
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure that the listenerThread is awake to shutdown properly
|
||||
synchronized (listenerThread) {
|
||||
listenerThread.notify();
|
||||
listenerThread.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue