From 0e15a903d92a9b13e1e83d78861b9daf043a176d Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 6 Apr 2018 19:37:18 +0200 Subject: [PATCH] Do not silently swallow exceptions in ChatStateManager --- .../jivesoftware/smackx/chatstates/ChatStateManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/chatstates/ChatStateManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/chatstates/ChatStateManager.java index 3570b6be3..2b92f0055 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/chatstates/ChatStateManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/chatstates/ChatStateManager.java @@ -23,6 +23,8 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.WeakHashMap; +import java.util.logging.Level; +import java.util.logging.Logger; import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.SmackException.NotConnectedException; @@ -62,6 +64,8 @@ import org.jxmpp.jid.EntityFullJid; */ public final class ChatStateManager extends Manager { + private static final Logger LOGGER = Logger.getLogger(ChatStateManager.class.getName()); + public static final String NAMESPACE = "http://jabber.org/protocol/chatstates"; private static final Map INSTANCES = new WeakHashMap<>(); @@ -135,12 +139,14 @@ public final class ChatStateManager extends Manager { Chat chat = ChatManager.getInstanceFor(connection()).chatWith(bareFrom); ExtensionElement extension = message.getExtension(NAMESPACE); + String chatStateElementName = extension.getElementName(); ChatState state; try { - state = ChatState.valueOf(extension.getElementName()); + state = ChatState.valueOf(chatStateElementName); } catch (Exception ex) { + LOGGER.log(Level.WARNING, "Invalid chat state element name: " + chatStateElementName, ex); return; }