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$2.run(XMPPTCPConnection.java:1667)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
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
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).