Hi all,
I have an issue with Smack 4.0.2 when receiving IQ stanzas. I didn’t create a provider because I need the raw unparsed stanza but
my IQ element’s 1st child is always missing. I traced it down to:
/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java, lines 642-646:
// Only handle unknown IQs of type result. Types of ‘get’ and ‘set’ which are not understood
// have to be answered with an IQ error response. See the code a few lines below
else if (IQ.Type.result == type){
// No Provider found for the IQ stanza, parse it to an UnparsedIQ instance
// so that the content of the IQ can be examined later on
iqPacket = new UnparsedResultIQ(parseContent(parser));
}
The issue is that parseContent() is used and this skips the IQ element’s first
child. I beleive this is an error because the spec says the the IQ element may
have one direct child, which is what I have. It has a custom namespace. I think
the result of parsing an unknown IQ result type should yeild the original msg.
To illustrate, I send something like this from the server:
and Smack gives my processPacket() method:
which is not what I sent…
If instead you did this:
// Only handle unknown IQs of type result. Types of ‘get’ and ‘set’ which are not understood
// have to be answered with an IQ error response. See the code a few lines below
else if (IQ.Type.result == type){
// No Provider found for the IQ stanza, parse it to an UnparsedIQ instance
// so that the content of the IQ can be examined later on
iqPacket = new UnparsedResultIQ(parseContentDepth(parser, parser.getDepth()));
}
it would work as expected, the whole unparsed IQ stanza, as received, would be handed over to the processPacket() method.