From e75f45082b279627f5e763fd8c4e562f618f9e55 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 31 Jan 2013 22:30:49 +0000 Subject: [PATCH] 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 --- source/org/jivesoftware/smackx/muc/MultiUserChat.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/org/jivesoftware/smackx/muc/MultiUserChat.java b/source/org/jivesoftware/smackx/muc/MultiUserChat.java index 870f4a38e..17c6f713e 100644 --- a/source/org/jivesoftware/smackx/muc/MultiUserChat.java +++ b/source/org/jivesoftware/smackx/muc/MultiUserChat.java @@ -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(); }