From 2f739662e5822bb5059c5e2241c188dbe9916a2c Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 21 Jan 2015 13:20:34 +0100 Subject: [PATCH] Make IQ.setType(Type) throw IllegalArgumentException when argument is 'null'. --- .../main/java/org/jivesoftware/smack/packet/IQ.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java index c66683515..070c9eb09 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java @@ -76,16 +76,18 @@ public abstract class IQ extends Packet { /** * Sets the type of the IQ packet. + *

+ * Since the type of an IQ must present, an IllegalArgmentException will be thrown when type is + * null. + *

* * @param type the type of the IQ packet. */ public void setType(Type type) { if (type == null) { - this.type = Type.get; - } - else { - this.type = type; + throw new IllegalArgumentException("type must not be null"); } + this.type = type; } public final String getChildElementName() {