From b849d4102b6d47cac737d431ba0e93df4174c5a2 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 20 Nov 2015 17:39:02 +0100 Subject: [PATCH] Allow for multiple 'null' fields in DataForm --- .../java/org/jivesoftware/smackx/xdata/packet/DataForm.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/packet/DataForm.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/packet/DataForm.java index 34c53156d..b68d57ab7 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/packet/DataForm.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/packet/DataForm.java @@ -219,7 +219,10 @@ public class DataForm implements ExtensionElement { */ public void addField(FormField field) { String fieldVariableName = field.getVariable(); - if (hasField(fieldVariableName)) { + // Form field values must be unique unless they are of type 'fixed', in + // which case their variable name may be 'null', and therefore could + // appear multiple times within the same form. + if (fieldVariableName != null && hasField(fieldVariableName)) { throw new IllegalArgumentException("This data form already contains a form field with the variable name '" + fieldVariableName + "'"); }