Program: 103333
Project: 103333
Buggy source:
/** 
 * Goes through the specified group and removes from all meta contacts, protocol specific contacts belonging to the specified <tt>groupToRemove</tt>. Note that this method won't undertake any calls to the protocol itself as it is used only to update the local contact list as a result of a server generated event.
 * @param parentMetaGroup  the MetaContactGroup whose children we should gothrough
 * @param groupToRemove the proto group that we want removed together withits children.
 */
private void locallyRemoveAllContactsForProvider(MetaContactGroupImpl parentMetaGroup,ContactGroup groupToRemove){
  Iterator<MetaContact> childrenContactsIter=parentMetaGroup.getChildContacts();
  while (childrenContactsIter.hasNext()) {
    MetaContactImpl child=(MetaContactImpl)childrenContactsIter.next();
    Iterator<Contact> contactsToRemove=child.getContactsForContactGroup(groupToRemove);
    child.removeContactsForGroup(groupToRemove);
    if (child.getContactCount() == 0) {
      parentMetaGroup.removeMetaContact(child);
      fireMetaContactEvent(child,parentMetaGroup,MetaContactEvent.META_CONTACT_REMOVED);
    }
 else {
      while (contactsToRemove.hasNext()) {
        fireProtoContactEvent(contactsToRemove.next(),ProtoContactEvent.PROTO_CONTACT_REMOVED,child,null);
      }
    }
  }
  Iterator<MetaContactGroup> subgroupsIter=parentMetaGroup.getSubgroups();
  while (subgroupsIter.hasNext()) {
    MetaContactGroupImpl subMetaGroup=(MetaContactGroupImpl)subgroupsIter.next();
    Iterator<ContactGroup> contactGroups=subMetaGroup.getContactGroups();
    ContactGroup protoGroup=null;
    while (contactGroups.hasNext()) {
      protoGroup=contactGroups.next();
      if (groupToRemove == protoGroup.getParentContactGroup())       this.locallyRemoveAllContactsForProvider(subMetaGroup,protoGroup);
    }
    if (subMetaGroup.countSubgroups() == 0 && subMetaGroup.countChildContacts() == 0) {
      parentMetaGroup.removeSubgroup(subMetaGroup);
      fireMetaContactGroupEvent(subMetaGroup,groupToRemove.getProtocolProvider(),protoGroup,MetaContactGroupEvent.META_CONTACT_GROUP_REMOVED);
    }
  }
  parentMetaGroup.removeProtoGroup(groupToRemove);
}

Fixed version (ground truth):
/** 
 * Goes through the specified group and removes from all meta contacts, protocol specific contacts belonging to the specified <tt>groupToRemove</tt>. Note that this method won't undertake any calls to the protocol itself as it is used only to update the local contact list as a result of a server generated event.
 * @param parentMetaGroup  the MetaContactGroup whose children we should gothrough
 * @param groupToRemove the proto group that we want removed together withits children.
 */
private void locallyRemoveAllContactsForProvider(MetaContactGroupImpl parentMetaGroup,ContactGroup groupToRemove){
  Iterator<MetaContact> childrenContactsIter=parentMetaGroup.getChildContacts();
  while (childrenContactsIter.hasNext()) {
    MetaContactImpl child=(MetaContactImpl)childrenContactsIter.next();
    Iterator<Contact> contactsToRemove=child.getContactsForContactGroup(groupToRemove);
    child.removeContactsForGroup(groupToRemove);
    if (child.getContactCount() == 0) {
      parentMetaGroup.removeMetaContact(child);
      fireMetaContactEvent(child,parentMetaGroup,MetaContactEvent.META_CONTACT_REMOVED);
    }
 else {
      while (contactsToRemove.hasNext()) {
        fireProtoContactEvent(contactsToRemove.next(),ProtoContactEvent.PROTO_CONTACT_REMOVED,child,null);
      }
    }
  }
  Iterator<MetaContactGroup> subgroupsIter=parentMetaGroup.getSubgroups();
  while (subgroupsIter.hasNext()) {
    MetaContactGroupImpl subMetaGroup=(MetaContactGroupImpl)subgroupsIter.next();
    Iterator<ContactGroup> contactGroups=subMetaGroup.getContactGroups();
    ContactGroup protoGroup=null;
    while (contactGroups.hasNext()) {
      protoGroup=contactGroups.next();
      if (groupToRemove == protoGroup.getParentContactGroup())       this.locallyRemoveAllContactsForProvider(subMetaGroup,protoGroup);
    }
    if (subMetaGroup.countSubgroups() == 0 && subMetaGroup.countChildContacts() == 0 && subMetaGroup.countContactGroups() == 0) {
      parentMetaGroup.removeSubgroup(subMetaGroup);
      fireMetaContactGroupEvent(subMetaGroup,groupToRemove.getProtocolProvider(),protoGroup,MetaContactGroupEvent.META_CONTACT_GROUP_REMOVED);
    }
  }
  parentMetaGroup.removeProtoGroup(groupToRemove);
}