mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-25 15:52:06 +01:00
Do not silently swallow exceptions in ChatStateManager
This commit is contained in:
parent
19a445ea02
commit
0e15a903d9
1 changed files with 7 additions and 1 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue