public static RoomListenerMultiplexor getRoomMultiplexor(XMPPConnection conn) {
62 synchronized (monitors) {
63 if (!monitors.containsKey(conn)) {
64   ; RoomListenerMultiplexor rm = new RoomListenerMultiplexor(conn, new RoomMultiplexFilter(),
65   ; new RoomMultiplexListener());
66
67   ; rm.init();
68
69   ; // We need to use a WeakReference because the monitor references the
70   ; // connection and this could prevent the GC from collecting the monitor
71   ; // when no other object references the monitor
72   ; monitors.put(conn, new WeakReference<RoomListenerMultiplexor>(rm));
73 }
74 // Return the InvitationsMonitor that monitors the connection
75 return monitors.get(conn).get();
76 }
77 }
78
Because you can get a NullPointerException in the case when the WeakReference has been GC'ed, since this method will return null. The fix is easy, the if statement should go from being "if (!monitors.containsKey(conn)) {" to "if (!monitors.containsKey(conn) || monitors.get(conn).get() == null) {"
http://www.igniterealtime.org/community/message/192927
This code is broken:
public static RoomListenerMultiplexor getRoomMultiplexor(XMPPConnection conn) {
62 synchronized (monitors) {
63 if (!monitors.containsKey(conn)) {
64   ; RoomListenerMultiplexor rm = new RoomListenerMultiplexor(conn, new RoomMultiplexFilter(),
65   ; new RoomMultiplexListener());
66
67   ; rm.init();
68
69   ; // We need to use a WeakReference because the monitor references the
70   ; // connection and this could prevent the GC from collecting the monitor
71   ; // when no other object references the monitor
72   ; monitors.put(conn, new WeakReference<RoomListenerMultiplexor>(rm));
73 }
74 // Return the InvitationsMonitor that monitors the connection
75 return monitors.get(conn).get();
76 }
77 }
78
Because you can get a NullPointerException in the case when the WeakReference has been GC'ed, since this method will return null. The fix is easy, the if statement should go from being "if (!monitors.containsKey(conn)) {" to "if (!monitors.containsKey(conn) || monitors.get(conn).get() == null) {"