powered by Jive Software

ConcurrentModification Exception in MultiUserChatManager.java


#1

I use Smack version 4.2.0 (4.2.0-rc2-49-gb9b8b1a-4.2 2017-03-10) on Android.

I use MultiUserChat with autoJoinOnResonnect set to true. When I get disconnected (e.g. turn my internet off) and then reconnect I get:

Process: de.achts.aos.leap.staging, PID: 3650
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:787)
at java.util.HashMap$KeyIterator.next(HashMap.java:814)
at java.util.Collections$UnmodifiableCollection$1.next(Collections.java:964)
at org.jivesoftware.smackx.muc.MultiUserChatManager$3$1.run(MultiUserChatManager.java:193)
at java.lang.Thread.run(Thread.java:818)

I think this is caused by the fact that the method MultiUserChatManager.getJoinedRooms() (MultiUserChatManager line 192) uses the same object that is being changed when calling muc.leave() (MultiUserChatManager line 202) and muc.join() (MultiUserChatManager line 212). I think a deep copy of joined rooms is needed there.


#2

Thanks for reporting. I’ve created SMACK-819.

I wonder if a CopyOnWriteArraySet wouldn’t be better suited.