Uploaded image for project: 'Smack'
  1. Smack
  2. SMACK-273

Bug in RoomListenerMultiplexor.java

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.0
    • Fix Version/s: 3.2.1
    • Component/s: None
    • Labels:
      None

      Description

      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 &nbsp ; RoomListenerMultiplexor rm = new RoomListenerMultiplexor(conn, new RoomMultiplexFilter(), 65 &nbsp ; new RoomMultiplexListener()); 66 67 &nbsp ; rm.init(); 68 69 &nbsp ; // We need to use a WeakReference because the monitor references the 70 &nbsp ; // connection and this could prevent the GC from collecting the monitor 71 &nbsp ; // when no other object references the monitor 72 &nbsp ; 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) {"

        Attachments

          Activity

            People

            Assignee:
            wolf.posdorfer Wolf P.
            Reporter:
            akrherz Daryl Herzmann
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: