From ec982f65e23fcfd0d0b61d2909128ba1c2c792f5 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 14 Oct 2018 12:07:51 +0200 Subject: [PATCH] Fix IndexOutOfBoundsException in FormField.getFirstValue() Fixes SMACK-838. --- .../java/org/jivesoftware/smackx/xdata/FormField.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/FormField.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/FormField.java index b45c139bc..5ecf7ab59 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/FormField.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/FormField.java @@ -261,12 +261,14 @@ public class FormField implements NamedElement { */ public String getFirstValue() { CharSequence firstValue; + synchronized (values) { + if (values.isEmpty()) { + return null; + } firstValue = values.get(0); } - if (firstValue == null) { - return null; - } + return firstValue.toString(); }