After upgrading from Smack 4.3.5 to 4.4.0 when sending an XMPP message to Firebase (fcm-xmpp.googleapis.com) we encounter the following error from the XMPPTCPConnection’s PackageReader while parsing packets in our logs:
org.jivesoftware.smack.xml.XmlPullParserException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1178]
Message: XML document structures must start and end within the same entity.
at org.jivesoftware.smack.xml.stax.StaxXmlPullParser.next(StaxXmlPullParser.java:194)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1140)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$700(XMPPTCPConnection.java:913)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:936)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1178]
Message: XML document structures must start and end within the same entity.
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:652)
at org.jivesoftware.smack.xml.stax.StaxXmlPullParser.next(StaxXmlPullParser.java:192)
... 4 more
A have a unit test to trigger this problem and to campare with the same message between the Smack versions.
Next I activated debug output via
setDebuggerFactory(ConsoleDebugger::new)
while configurationg the connection.
For 4.3.5 all runs fine a I get nice output.
Unfortunately, with Smack 4.4.0 using JXMPP 1.0.1 I end up with an error writing the debug output right after ouputting
XMPPConnection authenticated
while processing the actual message:
XMPPConnection closed due to an exception (XMPPTCPConnection[XXX] (0))
java.lang.UnsupportedOperationException
at org.jxmpp.xml.splitter.XmlSplitter.processChar(XmlSplitter.java:376)
at org.jxmpp.xml.splitter.XmlSplitter.write(XmlSplitter.java:155)
at java.base/java.io.Writer.write(Writer.java:290)
at java.base/java.io.Writer.write(Writer.java:249)
at java.base/java.io.Writer.append(Writer.java:322)
at org.jivesoftware.smack.debugger.SmackDebugger.lambda$newConnectionWriter$3(SmackDebugger.java:123)
at org.jivesoftware.smack.util.ObservableWriter.notifyListeners(ObservableWriter.java:103)
at org.jivesoftware.smack.util.ObservableWriter.flush(ObservableWriter.java:50)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.writePackets(XMPPTCPConnection.java:1353)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.access$4200(XMPPTCPConnection.java:1158)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter$1.run(XMPPTCPConnection.java:1208)
at java.base/java.lang.Thread.run(Thread.java:834)
This seems to be related to a CDATA section used in a custom ExtensionElement - e.g. build like this
<![CDATA[" + json + "]]>
While debugging I noticed the UnsupportedOperationException is for the case AFTER_COMMENT_BANG, the actual character processed is “[” and the content of the splittedPartBuffer is
<message><gcm xmlns="google:mobile:data"><![
I suspect this to be a bug, but it is likely unrelated to the actual issue I wanted to analyze.
Could you please give me any pointers how to quickly identify the cause of the “main issue” with the ParseError? The actual message sending is successful.
Thanks a lot,
Eric