powered by Jive Software

Wrong key in groupMetaCache evict

In the GroupManager class, the groupMetaCache has several forms of key. One of them is populated in the getSharedGroups(String userName) method, where the userName is the node string (for example, “user” where “user@domain/res” is the full jid).

However in several parts of the GroupManager class the evict of he cache is done using the bareJid. So i did this fix:

— a/src/java/org/jivesoftware/openfire/group/GroupManager.java

+++ b/src/java/org/jivesoftware/openfire/group/GroupManager.java

@@ -172,9 +172,7 @@ public class GroupManager {

             // Remove only the collection of groups the member belongs to.

             String member = (String) params.get("member");
  •            if(member != null) {
    
  •            groupMetaCache.remove(member);
    
  •            }
    
  •            evictCachedUserForGroup(member);
    
           }
    
           public void memberRemoved(Group group, Map params) {
    

@@ -184,9 +182,7 @@ public class GroupManager {

             // Remove only the collection of groups the member belongs to.

             String member = (String) params.get("member");
  •            if(member != null) {
    
  •            groupMetaCache.remove(member);
    
  •            }
    
  •            evictCachedUserForGroup(member);
    
           }
    
           public void adminAdded(Group group, Map params) {
    

@@ -196,9 +192,7 @@ public class GroupManager {

             // Remove only the collection of groups the member belongs to.

             String member = (String) params.get("admin");
  •            if(member != null) {
    
  •            groupMetaCache.remove(member);
    
  •            }
    
  •            evictCachedUserForGroup(member);
    
           }
    
           public void adminRemoved(Group group, Map params) {
    

@@ -208,8 +202,19 @@ public class GroupManager {

             // Remove only the collection of groups the member belongs to.

             String member = (String) params.get("admin");
  •            if(member != null) {
    
  •            groupMetaCache.remove(member);
    
  •            evictCachedUserForGroup(member);
    
  •        }
    
  •        private void evictCachedUserForGroup(String user) {
    
  •            if(user != null) {
    
  •                JID userJid = new JID(user);
    
  •                if (XMPPServer.getInstance().isLocal(userJid)) {
    
  •                    String username = userJid.getNode();
    
  •                    synchronized (username.intern()) {
    
  •                        groupMetaCache.remove(username);
    
  •                    }
    
  •                }
    
               }
    
           }
    

@@ -560,7 +565,7 @@ public class GroupManager {

  * @return all groups that an entity belongs to.

  */

 public Collection<Group> getGroups(JID user) {
  •    String key = user.toBareJID();
    
  •    String key = user.getNode();
    
       Collection<String> groupNames = (Collection<String>)groupMetaCache.get(key);
    
       if (groupNames == null) {

Thanks for the bug report. I have opened OF-867 to track this issue.

Created Pull Request with this change OF-867 Wrong key in groupMetaCache evict by akrherz · Pull Request #713 · igniterealtime/Openfire · GitHub