1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-23 02:58:00 +01:00

SMACK-439

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_3_1@13659 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Florian Schmaus 2013-05-17 22:04:31 +00:00 committed by flow
parent a934624787
commit 0951420d9c

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;