powered by Jive Software

Getting a Concurrent Modifications Exception when getting presence on Android


#1

Stack trace -

2018-10-19 14:55:07.841 23327-23948/com.mypackage E/AbstractXMPPConnection: Exception in packet listener
java.util.ConcurrentModificationException
at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:757)
at java.util.LinkedHashMap$LinkedKeyIterator.next(LinkedHashMap.java:780)
at org.jivesoftware.smack.roster.Roster.getPresence(Roster.java:944)
at MyPresenceManager.presenceUnavailable(MyPrecenseManager.java:189)
at org.jivesoftware.smack.roster.Roster$PresencePacketListener.processStanza(Roster.java:1533)
at org.jivesoftware.smack.AbstractXMPPConnection$6.run(AbstractXMPPConnection.java:1263)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)

Happens when manually querying for user presence. Example code -

Roster roster = Roster.getInstanceFor(mConnection);

for(User user : users){
     user.setPresence(roster.getPresence(presence.getFrom().asBareJid()));
}

#2

Which version of Smack do you use?


#3

4.2.4. Has there been a fix since?


#4

Yep, SMACK-841, fixed in Smack 4.3.1.