Hi everyone,
I’m currently using Smack 4.4.3 and I’m facing a strange problem.
Unfortunately, Smack does not support the XEP-0066 (Out-of-Band Data) so I’m implementing my own class for the xep.
I can correcly upload the file and send the oob with the url, but when I receive it in the newIncomingMessage of IncomingChatMessageListener I got the error
FATAL EXCEPTION: Smack Cached Executor
java.lang.ClassCastException: org.jivesoftware.smack.packet.StandardExtensionElement cannot be cast to …
So I added this line before the connection initialization
Smack receives the stanza and my OutOfBandData.Provider correctly parse the message. But now the newIncomingMessage is not raised anymore!
I also tried addSyncStanzaListener to the connection (with filter Message::class) but still nothing happen.
In the class org.jivesoftware.smack.provider.Provider.java there’s the method
public final E parse(XmlPullParser parser, XmlEnvironment outerXmlEnvironment)
This method calls the Provider I wrote for the Oob. Its parse method consumes the XmlPullParser till the end of the document (XmlPullParser.Event.END_DOCUMENT). Once finished, the provider super class calls the method
And here comes the problem. This method executes a loop
while (!(event == XmlPullParser.Event.END_ELEMENT && parser.getDepth() == depth))
Due to the previously parsed XmlPullParser (from my Oob class), this become an endless loop.
I fixed this issue by adding a break in the parse of my Oob class. Now the parsing ends before the XmlPullParser.Event.END_DOCUMENT and the subsequent loop exits correctly.
That was a problem in my code, but maybe the forwardToEndTagOfDepth should check if the parser is already at the end of the document to improve robustness.
Turns out that I was wrong. Smack has not yet support for OOB.
Now I understood you. It’s about END_DOCUMENT, when I read END_ELEMENT. I could imagine adding an assert statement that asserts that END_DOCUMENT does not appear (as it would break the methods API contract).