NullPointerException in XMPPTCPConnection:1667 using Stream Management


I am getting this exception while using latest snapshot version of smack for android (smack-android:4.1.0-beta2-SNAPSHOT).

java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.String org.jivesoftware.smack.packet.Packet.getPacketID()’ on a null object reference

at org.jivesoftware.smack.tcp.XMPPTCPConnection$

at java.util.concurrent.ThreadPoolExecutor.runWorker(

at java.util.concurrent.ThreadPoolExecutor$


I am quite sure that this is a bug in the smack library, but I was not able to find possible source of this bug in smack code.

BTW I was also sometimes encountering getting null packet as parameter in processPacket method of PacketListener (which was added as by addSyncPacketListener to XMPPTCPConnection). Maybe these two issues are connected somehow

1 Like

The only way that ‘null’ value could enter the ackedStanzas list is via the unacknowledgedStanzas.poll(). unacknowledgedStanzas.put() is guarded by a null check, but poll() would also return null if the queue is empty, which could be the cause if the stream mangement counters are for some reason off.

I always expected that Stream Management issues would be tough ones. This is a good example that it is really the case. In most cases a stacktrace is enough to get an idea what’s going wrong, and how to fix it. But this is not true in this case. While I can’t rule out that this is a bug in Smack, it’s also possible the other involved party is reporting wrong values.

Ideally you are able to reliable reproduce this error and collect a debug log output, i.e. a trace of the XMPP stream, and report this together with the stacktrace and exact Smack version (the git commit used).

Thanks for your report so far.

I was not able to reproduce this crash so far, but I will try…

I started to seeing this crash after I updated to beta2 so maybe it’s connected with this commit 970dcff since it’s the only commit in beta2 which has something to do with handledStanzasCount

BTW: which server do you use?

We are using ejabberd

I am still not able to reproduce this bug