mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-26 20:47:58 +01:00
SMACK-270 MultiUserChat relied on finalize() being called in order to remove packet listeners and the association with RoomListenerMultiplexor. The PacketListeners are referenced by Connection, which meant that MultiUserChat is always strongly reachable until the connection dies.
This patch introduces an new MultiUserChat.cleanup() method that is called when userHashLeft() is triggered. Thanks to Stuart Chalmers and scgmile for reporting this. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@13418 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
a75d2d7d0d
commit
e75f45082b
1 changed files with 7 additions and 3 deletions
|
@ -1986,6 +1986,7 @@ public class MultiUserChat {
|
|||
return;
|
||||
}
|
||||
rooms.remove(room);
|
||||
cleanup();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2530,7 +2531,7 @@ public class MultiUserChat {
|
|||
}
|
||||
}
|
||||
|
||||
protected void finalize() throws Throwable {
|
||||
private void cleanup() {
|
||||
try {
|
||||
if (connection != null) {
|
||||
roomListenerMultiplexor.removeRoom(room);
|
||||
|
@ -2539,10 +2540,13 @@ public class MultiUserChat {
|
|||
connection.removePacketListener(connectionListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
protected void finalize() throws Throwable {
|
||||
cleanup();
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue