addExtension on Iq serialised 2x

Hi,

When I define a very basic IQ stanza and add an RSMSet extension, it is serialized two times:

Query query = new Query(“queryId”);

RSMSet rsmSet = new RSMSet(20);

query.addExtension(rsmSet);

System.out.println(query.toXML().toString());

Will produce the following String with two RSMSets in it:

<?xml version="1.0"?>
<set xmlns="[http://jabber.org/protocol/rsm](http://jabber.org/protocol/rsm)">

20

<set xmlns="[http://jabber.org/protocol/rsm](http://jabber.org/protocol/rsm)">

20

BTW, this was in the Smack 4.1.2-SNAPSHOT release.

I guess your Query’s toXML is flawed.

Ahhh yeah actually it is not mine. But the Query-class overrides this method:

protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {

xml.attribute(“queryid”, this.getQueryID());

xml.rightAngleBracket();

Iterator i$ = this.getExtensions().iterator();

while(i$.hasNext()) {

ExtensionElement p = (ExtensionElement)i$.next();

xml.append(p.toXML());

}

return xml;

}

But the extensions are already added in IQ.getChildElementXML() so should be omitted here.

Thanks,

Andrej

Ahhh yeah actually it is not mine. But the Query-class overrides this method:
Which query class is this? It sounds like an awful generic name for an IQ.

Yes I agree it’s way to generic! It is not open-source so unfortunately I cannot share the source.