From 2aeb58b7763bdc46702848739d8af4c0f1abfaef Mon Sep 17 00:00:00 2001 From: Matt Tucker Date: Mon, 4 Aug 2003 21:58:53 +0000 Subject: [PATCH] Noted that IQ packets can't have extensions. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2009 b35dd754-fafc-0310-a699-88a17e54d16e --- .../org/jivesoftware/smack/packet/Packet.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/org/jivesoftware/smack/packet/Packet.java b/source/org/jivesoftware/smack/packet/Packet.java index d33d3ebc1..35ef94ad4 100644 --- a/source/org/jivesoftware/smack/packet/Packet.java +++ b/source/org/jivesoftware/smack/packet/Packet.java @@ -206,6 +206,11 @@ public abstract class Packet { * class to handle custom parsing. In that case, the type of the Object * will be determined by the provider. * + *

Note: According to the XMPP specification, IQ packets cannot contain + * packet extensions. Instead, they must contain only a single XML sub-document, + * which is returned via the {@link IQ#getChildElementXML()} method. Therefore, + * attempting to add an extension to an IQ packet will silently fail. + * * @param elementName the XML element name of the packet extension. * @param namespace the XML element namespace of the packet extension. * @return the extension, or null if it doesn't exist. @@ -226,9 +231,19 @@ public abstract class Packet { /** * Adds a packet extension to the packet. * + *

Note: According to the XMPP specification, IQ packets cannot contain + * packet extensions. Instead, they must contain only a single XML sub-document, + * which is returned via the {@link IQ#getChildElementXML()} method. Therefore, + * attempting to add an extension to an IQ packet will silently fail. + * * @param extension a packet extension. */ public synchronized void addExtension(PacketExtension extension) { + // If the packet is an IQ packet, ignore trying to add an extension to it. + if (this instanceof IQ) { + return; + } + if (packetExtensions == null) { packetExtensions = new ArrayList(); } @@ -238,6 +253,11 @@ public abstract class Packet { /** * Removes a packet extension from the packet. * + *

Note: According to the XMPP specification, IQ packets cannot contain + * packet extensions. Instead, they must contain only a single XML sub-document, + * which is returned via the {@link IQ#getChildElementXML()} method. Therefore, + * attempting to add an extension to an IQ packet will silently fail. + * * @param extension the packet extension to remove. */ public synchronized void removeExtension(PacketExtension extension) {