1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-29 09:42:06 +01:00

Do not silently swallow exceptions in ChatStateManager

This commit is contained in:
Florian Schmaus 2018-04-06 19:37:18 +02:00
parent 19a445ea02
commit 0e15a903d9

View file

@ -23,6 +23,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
@ -62,6 +64,8 @@ import org.jxmpp.jid.EntityFullJid;
*/ */
public final class ChatStateManager extends Manager { 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"; public static final String NAMESPACE = "http://jabber.org/protocol/chatstates";
private static final Map<XMPPConnection, ChatStateManager> INSTANCES = new WeakHashMap<>(); private static final Map<XMPPConnection, ChatStateManager> INSTANCES = new WeakHashMap<>();
@ -135,12 +139,14 @@ public final class ChatStateManager extends Manager {
Chat chat = ChatManager.getInstanceFor(connection()).chatWith(bareFrom); Chat chat = ChatManager.getInstanceFor(connection()).chatWith(bareFrom);
ExtensionElement extension = message.getExtension(NAMESPACE); ExtensionElement extension = message.getExtension(NAMESPACE);
String chatStateElementName = extension.getElementName();
ChatState state; ChatState state;
try { try {
state = ChatState.valueOf(extension.getElementName()); state = ChatState.valueOf(chatStateElementName);
} }
catch (Exception ex) { catch (Exception ex) {
LOGGER.log(Level.WARNING, "Invalid chat state element name: " + chatStateElementName, ex);
return; return;
} }