Hi,
I’m working on Omemo encryption for MUC with smack 4.2.1-SNAPSHOT. When user is receiving messages from muc, it is giving entity full jid nil of sender which cause NPE in MultiUserChat for getting occupant of muc.
OmemoService.java
private static OmemoDevice getSender(OmemoManager omemoManager, Stanza stanza) {
OmemoElement omemoElement = (OmemoElement)stanza.getExtension(“encrypted”, “eu.siacs.conversations.axolotl”);
BareJid sender = stanza.getFrom().asBareJid(); __ /* I think, instead of using BareJid of sender we can use Jid which would easily be converted into EntityFullJid or EntityBareJid. */__
if(isMucMessage(omemoManager, stanza)) {
MultiUserChatManager mucm = MultiUserChatManager.getInstanceFor(omemoManager.getConnection());
MultiUserChat muc = mucm.getMultiUserChat(sender.asEntityBareJidIfPossible());
sender = muc.getOccupant(sender.asEntityFullJidIfPossible()).getJid().asBareJid(); ___ /* Getting entityFullJid null */___
}
if(sender == null) {
throw new AssertionError(“Sender is null.”);
} else {
return new OmemoDevice(sender, omemoElement.getHeader().getSid());
}
}
Exception:
Exception in async packet listener
java.lang.NullPointerException: Attempt to invoke virtual method ‘int java.lang.Object.hashCode()’ on a null object reference
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:746)
at org.jivesoftware.smackx.muc.MultiUserChat.getOccupantPresence(MultiUserChat.jav a:1667)
at org.jivesoftware.smackx.muc.MultiUserChat.getOccupant(MultiUserChat.java:1680)