private Set<String> getKnownGroupNamesFromKeys() {
        Set<String> result = knownGroupNamesFromKeys;
        if (result == null) {
            synchronized(this) {
                result = knownGroupNamesFromKeys;
                if (result == null) {
                    result = new HashSet<>();
                    // add all the groups into the group set
                    for (K key : keySet()) {
                        Group group = Group.resolveFrom(key);
                        if (group != null) {
                            result.add(group.getName());
                        }
                    }
                    knownGroupNamesFromKeys = result.isEmpty() ? null : result;
                }
            }
        }
        return result;
    }
Accessor uses the  "double-check idiom" (j2se 5.0+) for proper lazy instantiation.
Additionally, nothing is cached until there is at least one group in the map's keys.

@return the known group names among the items in the list
xmppserver/src/main/java/org/jivesoftware/openfire/group/ConcurrentGroupMap.java