Export to GitHub

asmack - issue #82

MultiUserChat.addInvitationListener(conn, "") throws nullpointerexception when reconnecting


Posted on May 12, 2013 by Helpful Giraffe

Hi, I got a NullPointerException on MultiUserChat.addInvitationListener when connecting at 2nd ,I think InvitationsMonitor.getInvitationsMonitor(conn) in MultiUserChat.java return null

public static InvitationsMonitor getInvitationsMonitor(Connection conn) { synchronized (monitors) { if (!monitors.containsKey(conn)) { // We need to use a WeakReference because the monitor references the // connection and this could prevent the GC from collecting the monitor // when no other object references the monitor monitors.put(conn, new WeakReference<InvitationsMonitor>(new InvitationsMonitor(conn))); } // Return the InvitationsMonitor that monitors the connection return monitors.get(conn).get(); }

It may be fixed by change "if (!monitors.containsKey(conn))" to "if (!monitors.containsKey(conn) || monitors.get(conn).get() == null)"

can you give me some direction about it? Thanks

Comment #1

Posted on May 12, 2013 by Swift Rabbit

Filled as upstream bug [SMACK-438|http://issues.igniterealtime.org/browse/SMACK-438]

Comment #2

Posted on May 21, 2013 by Helpful Giraffe

Thank you very much! Concurrent WeakHashMap is a good idea,very enlightening.I'll wait fixed version of aSmack. Thanks!

Comment #3

Posted on May 21, 2013 by Helpful Giraffe

Comment deleted

Status: Done

Labels:
Type-Defect Priority-Medium