public void broadcast(RosterItem item, boolean optimize) {
        // Do not broadcast items with status FROM that exist only because of shared groups
        if (optimize && item.isOnlyShared() && item.getSubStatus() == RosterItem.SUB_FROM) {
            return;
        }
        // Set the groups to broadcast (include personal and shared groups)
        List<String> groups = new ArrayList<>(item.getGroups());
        for (Group sharedGroup : item.getSharedGroups()) {
            String displayName = sharedGroup.getSharedDisplayName();
            if (displayName != null) {
                groups.add(displayName);
            }
        }

        org.xmpp.packet.Roster roster = new org.xmpp.packet.Roster();
        roster.setType(IQ.Type.set);
        roster.addItem(item.getJid(), item.getNickname(),
                getAskStatus(item.getAskStatus()),
                org.xmpp.packet.Roster.Subscription.valueOf(item.getSubStatus().getName()),
                groups);
        broadcast(roster);
    }
Broadcasts the RosterItem to all the connected resources of this user. Due to performance
optimizations and due to some clients errors that are showing items with subscription status
FROM we added a flag that indicates if a roster items that exists only because of a shared
group with subscription status FROM will not be sent.

@param item     the item to broadcast.
@param optimize true indicates that items that exists only because of a shared
                group with subscription status FROM will not be sent
xmppserver/src/main/java/org/jivesoftware/openfire/roster/Roster.java