Suddenly I have a very strange issue with Smacks XMPPTCPConnection.
During connection establishing, Smack sends
<stream:stream xmlns='jabber:client' to='server.tld' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' email@example.com' xml:lang='de-DE'>
to open a stream. The server responds with
<stream:stream id='5332463414214598760' version='1.0' xml:lang='de-DE' xmlns:stream='http://etherx.jabber.org/streams' firstname.lastname@example.org' from='server.tld' xmlns='jabber:client'> <stream:features> <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'> <required/> </starttls> </stream:features>
So far, so good. However, now Smack now immediately throws a ConcurrentModificationException while trying to write to the Stream:
2019-09-16 17:34:20.993 10659-10798/org.mercury_im.messenger I/AbstractXMPPConnection: Connection was already disconnected when attempting to handle java.util.ConcurrentModificationException java.util.ConcurrentModificationException at java.util.ArrayList$Itr.next(ArrayList.java:860) at java.util.Collections$UnmodifiableCollection$1.next(Collections.java:1084) at org.jivesoftware.smack.util.XmlStringBuilder.appendXmlTo(XmlStringBuilder.java:642) at org.jivesoftware.smack.util.XmlStringBuilder.write(XmlStringBuilder.java:622) at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.writePackets(XMPPTCPConnection.java:1352) at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.access$3400(XMPPTCPConnection.java:1159) at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter$1.run(XMPPTCPConnection.java:1211) at java.lang.Thread.run(Thread.java:764)
I’m a little bit baffled, as I can’t find what I changed in my code to cause this behavior.
I already reverted to a known good revision, but for some reason the issue is persistent and happens both with Smack as dependency/composite build, and on emulator/hardware device.
I also tested on multiple servers already to rule out that the server is at fault.