From f12fe2264a34418967be74bf0d0b58cad31c3efc Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 8 Nov 2020 19:37:41 +0100 Subject: [PATCH] [muc] Only retrieve MUCUser once in Presence listener --- .../java/org/jivesoftware/smackx/muc/MultiUserChat.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java index 054d0ec22..b75f44d5e 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java @@ -195,6 +195,7 @@ public class MultiUserChat { } final EntityFullJid myRoomJID = myRoomJid; final boolean isUserStatusModification = presence.getFrom().equals(myRoomJID); + final MUCUser mucUser = MUCUser.from(packet); switch (presence.getType()) { case available: @@ -205,9 +206,8 @@ public class MultiUserChat { MUCAffiliation oldAffiliation = mucExtension.getItem().getAffiliation(); MUCRole oldRole = mucExtension.getItem().getRole(); // Get the new occupant's affiliation & role - mucExtension = MUCUser.from(packet); - MUCAffiliation newAffiliation = mucExtension.getItem().getAffiliation(); - MUCRole newRole = mucExtension.getItem().getRole(); + MUCAffiliation newAffiliation = mucUser.getItem().getAffiliation(); + MUCRole newRole = mucUser.getItem().getRole(); // Fire role modification events checkRoleModifications(oldRole, newRole, isUserStatusModification, from); // Fire affiliation modification events @@ -228,7 +228,6 @@ public class MultiUserChat { break; case unavailable: occupantsMap.remove(from); - MUCUser mucUser = MUCUser.from(packet); if (mucUser != null && mucUser.hasStatus()) { if (isUserStatusModification) { userHasLeft();