1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-16 04:12:04 +01:00

SMACK-439

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@13649 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Florian Schmaus 2013-05-12 14:51:50 +00:00 committed by flow
parent 37f6bf12da
commit 2195d66e4d

View file

@ -2573,9 +2573,15 @@ public class MultiUserChat {
private static class InvitationsMonitor implements ConnectionListener { private static class InvitationsMonitor implements ConnectionListener {
// We use a WeakHashMap so that the GC can collect the monitor when the // We use a WeakHashMap so that the GC can collect the monitor when the
// connection is no longer referenced by any object. // 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<Connection, WeakReference<InvitationsMonitor>> monitors = private final static Map<Connection, WeakReference<InvitationsMonitor>> monitors =
new WeakHashMap<Connection, WeakReference<InvitationsMonitor>>(); new WeakHashMap<Connection, WeakReference<InvitationsMonitor>>();
// We don't use a synchronized List here because it would break the semantic of (add|remove)InvitationListener
private final List<InvitationListener> invitationsListeners = private final List<InvitationListener> invitationsListeners =
new ArrayList<InvitationListener>(); new ArrayList<InvitationListener>();
private Connection connection; private Connection connection;