From 2195d66e4d322c1c329710e56af3c1a85beee08e Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 12 May 2013 14:51:50 +0000 Subject: [PATCH] SMACK-439 git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@13649 b35dd754-fafc-0310-a699-88a17e54d16e --- source/org/jivesoftware/smackx/muc/MultiUserChat.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/org/jivesoftware/smackx/muc/MultiUserChat.java b/source/org/jivesoftware/smackx/muc/MultiUserChat.java index 4800011fd..d657ee711 100644 --- a/source/org/jivesoftware/smackx/muc/MultiUserChat.java +++ b/source/org/jivesoftware/smackx/muc/MultiUserChat.java @@ -2573,9 +2573,15 @@ public class MultiUserChat { private static class InvitationsMonitor implements ConnectionListener { // We use a WeakHashMap so that the GC can collect the monitor when the // connection is no longer referenced by any object. + // Note that when the InvitationsMonitor is used, i.e. when there are InvitationListeners, it will add a + // PacketListener to the Connection and therefore a strong reference from the Connection to the + // InvitationsMonior will exists, preventing it from beeing gc'ed. After the last InvitationListener is gone, + // the PacketListener will get removed (cancel()) allowing the garbage collection of the InvitationsMonitor + // instance. private final static Map> monitors = new WeakHashMap>(); + // We don't use a synchronized List here because it would break the semantic of (add|remove)InvitationListener private final List invitationsListeners = new ArrayList(); private Connection connection;