Program: 103011
Project: 103011
Buggy source:
/** 
 * Filters the children in the given <tt>MetaContactGroup</tt> to match the given <tt>filterPattern</tt> and stores the result in the given <tt>treeModel</tt>.
 * @param filterPattern the pattern to filter through
 * @param parentGroup the <tt>MetaContactGroup</tt> to filter
 * @param query the object that tracks the query
 * @param resultCount the initial result count we would insert directly tothe contact list without firing events
 */
public void queryMetaContactSource(Pattern filterPattern,MetaContactGroup parentGroup,MetaContactQuery query,int resultCount){
  Iterator<MetaContact> childContacts=parentGroup.getChildContacts();
  while (childContacts.hasNext() && !query.isCanceled()) {
    MetaContact metaContact=childContacts.next();
    if (isMatching(filterPattern,metaContact)) {
      resultCount++;
      if (resultCount <= INITIAL_CONTACT_COUNT) {
        UIGroup uiGroup=null;
synchronized (parentGroup) {
          uiGroup=MetaContactListSource.getUIGroup(parentGroup);
        }
        if (!MetaContactListSource.isRootGroup(parentGroup)) {
synchronized (parentGroup) {
            if (uiGroup == null)             uiGroup=MetaContactListSource.createUIGroup(parentGroup);
          }
        }
        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=parentGroup.getSubgroups();
  while (subgroups.hasNext() && !query.isCanceled()) {
    MetaContactGroup subgroup=subgroups.next();
    queryMetaContactSource(filterPattern,subgroup,query,resultCount);
  }
}

Fixed version (ground truth):
/** 
 * Filters the children in the given <tt>MetaContactGroup</tt> to match the given <tt>filterPattern</tt> and stores the result in the given <tt>treeModel</tt>.
 * @param filterPattern the pattern to filter through
 * @param parentGroup the <tt>MetaContactGroup</tt> to filter
 * @param query the object that tracks the query
 * @param resultCount the initial result count we would insert directly tothe contact list without firing events
 */
public void queryMetaContactSource(Pattern filterPattern,MetaContactGroup parentGroup,MetaContactQuery query,int resultCount){
  Iterator<MetaContact> childContacts=parentGroup.getChildContacts();
  while (childContacts.hasNext() && !query.isCanceled()) {
    MetaContact metaContact=childContacts.next();
    if (isMatching(filterPattern,metaContact)) {
      resultCount++;
      if (resultCount <= INITIAL_CONTACT_COUNT) {
        UIGroup uiGroup=null;
synchronized (parentGroup) {
          uiGroup=MetaContactListSource.getUIGroup(parentGroup);
        }
        if (!MetaContactListSource.isRootGroup(parentGroup)) {
synchronized (parentGroup) {
            if (uiGroup == null)             uiGroup=MetaContactListSource.createUIGroup(parentGroup);
          }
        }
        UIContact newUIContact;
        boolean uiContactCreated=false;
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=parentGroup.getSubgroups();
  while (subgroups.hasNext() && !query.isCanceled()) {
    MetaContactGroup subgroup=subgroups.next();
    queryMetaContactSource(filterPattern,subgroup,query,resultCount);
  }
}