Program: 103008
Project: 103008
Buggy source:
/** 
 * Adds all contacts contained in the given <tt>MetaContactGroup</tt> matching the current filter and not contained in the contact list.
 * @param metaGroup the <tt>MetaContactGroup</tt>, which matching contactsto add
 * @param query the <tt>MetaContactQuery</tt> that notifies interestedlisteners of the results of this matching
 * @param resultCount the initial result count we would insert directly tothe contact list without firing events
 */
private void addMatching(MetaContactGroup metaGroup,MetaContactQuery query,int resultCount){
  Iterator<MetaContact> childContacts=metaGroup.getChildContacts();
  while (childContacts.hasNext() && !query.isCanceled()) {
    MetaContact metaContact=childContacts.next();
    if (isMatching(metaContact)) {
      resultCount++;
      if (resultCount <= INITIAL_CONTACT_COUNT) {
        UIGroup uiGroup=null;
synchronized (metaGroup) {
          uiGroup=MetaContactListSource.getUIGroup(metaGroup);
        }
        if (!MetaContactListSource.isRootGroup(metaGroup)) {
synchronized (metaGroup) {
            if (uiGroup == null)             uiGroup=MetaContactListSource.createUIGroup(metaGroup);
          }
        }
        if (logger.isDebugEnabled())         logger.debug("String_Node_Str" + metaContact.getDisplayName());
        UIContact newUIContact;
synchronized (metaContact) {
          newUIContact=MetaContactListSource.createUIContact(metaContact);
        }
        GuiActivator.getContactList().addContact(newUIContact,uiGroup,true,true);
        query.setInitialResultCount(resultCount);
      }
 else       query.fireQueryEvent(metaContact);
    }
  }
  if (query.isCanceled())   return;
  Iterator<MetaContactGroup> subgroups=metaGroup.getSubgroups();
  while (subgroups.hasNext() && !query.isCanceled()) {
    MetaContactGroup subgroup=subgroups.next();
    if (isMatching(subgroup)) {
      UIGroup uiGroup;
synchronized (subgroup) {
        uiGroup=MetaContactListSource.getUIGroup(subgroup);
        if (uiGroup == null)         uiGroup=MetaContactListSource.createUIGroup(subgroup);
      }
      GuiActivator.getContactList().addGroup(uiGroup,true);
      addMatching(subgroup,query,resultCount);
    }
  }
}

Fixed version (ground truth):
/** 
 * Adds all contacts contained in the given <tt>MetaContactGroup</tt> matching the current filter and not contained in the contact list.
 * @param metaGroup the <tt>MetaContactGroup</tt>, which matching contactsto add
 * @param query the <tt>MetaContactQuery</tt> that notifies interestedlisteners of the results of this matching
 * @param resultCount the initial result count we would insert directly tothe contact list without firing events
 */
private void addMatching(MetaContactGroup metaGroup,MetaContactQuery query,int resultCount){
  Iterator<MetaContact> childContacts=metaGroup.getChildContacts();
  while (childContacts.hasNext() && !query.isCanceled()) {
    MetaContact metaContact=childContacts.next();
    if (isMatching(metaContact)) {
      resultCount++;
      if (resultCount <= INITIAL_CONTACT_COUNT) {
        UIGroup uiGroup=null;
synchronized (metaGroup) {
          uiGroup=MetaContactListSource.getUIGroup(metaGroup);
        }
        if (!MetaContactListSource.isRootGroup(metaGroup)) {
synchronized (metaGroup) {
            if (uiGroup == null)             uiGroup=MetaContactListSource.createUIGroup(metaGroup);
          }
        }
        if (logger.isDebugEnabled())         logger.debug("String_Node_Str" + metaContact.getDisplayName());
        UIContact newUIContact;
synchronized (metaContact) {
          newUIContact=MetaContactListSource.getUIContact(metaContact);
          if (newUIContact == null) {
            newUIContact=MetaContactListSource.createUIContact(metaContact);
            GuiActivator.getContactList().addContact(newUIContact,uiGroup,true,true);
          }
        }
        query.setInitialResultCount(resultCount);
      }
 else {
synchronized (metaContact) {
          if (MetaContactListSource.getUIContact(metaContact) == null) {
            query.fireQueryEvent(metaContact);
          }
        }
      }
    }
  }
  if (query.isCanceled())   return;
  Iterator<MetaContactGroup> subgroups=metaGroup.getSubgroups();
  while (subgroups.hasNext() && !query.isCanceled()) {
    MetaContactGroup subgroup=subgroups.next();
    if (isMatching(subgroup)) {
      UIGroup uiGroup;
synchronized (subgroup) {
        uiGroup=MetaContactListSource.getUIGroup(subgroup);
        if (uiGroup == null)         uiGroup=MetaContactListSource.createUIGroup(subgroup);
      }
      GuiActivator.getContactList().addGroup(uiGroup,true);
      addMatching(subgroup,query,resultCount);
    }
  }
}