From 0951420d9c4c68d99fc4a4315cb9b44acb527c3c Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 17 May 2013 22:04:31 +0000 Subject: [PATCH] SMACK-439 git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_3_1@13659 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;