From 19469b0faf4e909a551a3e2c862c3d5b58b44792 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 20 Nov 2015 21:08:12 +0100 Subject: [PATCH] Fix NPE in ChatManager: Check if null bareJidChats is a ConcurrentHashMap which does not allow 'null' keys, thus get(null) returns a NPE. And asEntityBareJidIfPossible may return 'null', this could happen. --- .../main/java/org/jivesoftware/smack/chat/ChatManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java b/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java index 9351b233b..9d7f854e8 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java @@ -322,7 +322,10 @@ public final class ChatManager extends Manager{ Chat match = jidChats.get(userJID); if (match == null && (matchMode == MatchMode.BARE_JID)) { - match = baseJidChats.get(userJID.asEntityBareJidIfPossible()); + EntityBareJid entityBareJid = userJID.asEntityBareJidIfPossible(); + if (entityBareJid != null) { + match = baseJidChats.get(entityBareJid); + } } return match; }