From d6ebb884e7dcd2e0daab6b0c8f732b3c9d02b588 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 23 Nov 2016 17:55:16 +0100 Subject: [PATCH] Ad-Hoc Commands: 'type' attribute is optional Fixes SMACK-741 --- .../commands/provider/AdHocCommandDataProvider.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/provider/AdHocCommandDataProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/provider/AdHocCommandDataProvider.java index ff0a81608..72b5389d3 100755 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/provider/AdHocCommandDataProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/provider/AdHocCommandDataProvider.java @@ -95,8 +95,14 @@ public class AdHocCommandDataProvider extends IQProvider { adHocCommandData.setForm(dataFormProvider.parse(parser)); } else if (parser.getName().equals("note")) { - AdHocCommandNote.Type type = AdHocCommandNote.Type.valueOf( - parser.getAttributeValue("", "type")); + String typeString = parser.getAttributeValue("", "type"); + AdHocCommandNote.Type type; + if (typeString != null) { + type = AdHocCommandNote.Type.valueOf(typeString); + } else { + // Type is optional and 'info' if not present. + type = AdHocCommandNote.Type.info; + } String value = parser.nextText(); adHocCommandData.addNote(new AdHocCommandNote(type, value)); }