Program: 69990
Project: 69990
Buggy source:
private List<BGTableItem> search(SearchEvent event){
  Long id=event.getId();
  String name=event.getName();
  String description=event.getDescription();
  String ownerName=event.getOwnerName();
  SearchBusinessGroupParams params=new SearchBusinessGroupParams();
  if (id != null) {
    params.setKeys(Collections.singletonList(id));
  }
  params.setName(StringHelper.containsNonWhitespace(name) ? name : null);
  params.setDescription(StringHelper.containsNonWhitespace(description) ? description : null);
  params.setOwnerName(StringHelper.containsNonWhitespace(ownerName) ? ownerName : null);
  params.setOwner(event.isOwner());
  params.setAttendee(event.isAttendee());
  params.setWaiting(event.isWaiting());
  params.setPublicGroup(event.isPublicGroups());
  params.setIdentity(getIdentity());
  List<BusinessGroup> groups;
  if (admin) {
    if (event.isAttendee() || event.isOwner()) {
      params.setIdentity(getIdentity());
    }
    groups=businessGroupService.findBusinessGroups(params,null,0,-1);
  }
 else {
    if (!event.isAttendee() && !event.isOwner() && !event.isWaiting()&& !event.isPublicGroups()) {
      params.setPublicGroup(true);
    }
    groups=businessGroupService.findBusinessGroups(params,null,0,-1);
  }
  List<Long> groupsWithMembership=businessGroupService.isIdentityInBusinessGroups(getIdentity(),groups);
  Set<Long> memberships=new HashSet<Long>(groupsWithMembership);
  List<Long> resourceKeys=new ArrayList<Long>();
  for (  BusinessGroup group : groups) {
    resourceKeys.add(group.getResource().getKey());
  }
  List<BGRepositoryEntryRelation> resources=businessGroupService.findRelationToRepositoryEntries(groups,0,-1);
  List<OLATResourceAccess> resourcesWithAC=acFrontendManager.getAccessMethodForResources(resourceKeys,true,new Date());
  List<BGTableItem> items=new ArrayList<BGTableItem>();
  for (  BusinessGroup group : groups) {
    Long oresKey=group.getResource().getKey();
    List<PriceMethodBundle> accessMethods=null;
    for (    OLATResourceAccess access : resourcesWithAC) {
      if (oresKey.equals(access.getResource().getKey())) {
        accessMethods=access.getMethods();
        break;
      }
    }
    Boolean allowLeave=memberships.contains(group.getKey()) ? Boolean.TRUE : null;
    Boolean allowDelete=admin ? Boolean.TRUE : null;
    boolean accessControl=(accessMethods != null);
    boolean member=memberships.contains(group.getKey());
    List<BGRepositoryEntryRelation> relations=new ArrayList<BGRepositoryEntryRelation>();
    for (    BGRepositoryEntryRelation resource : resources) {
      if (group.getKey().equals(resource.getGroupKey())) {
        relations.add(resource);
        if (relations.size() >= 3) {
          break;
        }
      }
    }
    BGTableItem tableItem=new BGTableItem(group,member,allowLeave,allowDelete,accessControl,accessMethods);
    tableItem.setRelations(relations);
    items.add(tableItem);
  }
  return items;
}

Fixed version (ground truth):
private List<BGTableItem> search(SearchEvent event){
  Long id=event.getId();
  String name=event.getName();
  String description=event.getDescription();
  String ownerName=event.getOwnerName();
  SearchBusinessGroupParams params=new SearchBusinessGroupParams();
  if (id != null) {
    params.setGroupKeys(Collections.singletonList(id));
  }
  params.setName(StringHelper.containsNonWhitespace(name) ? name : null);
  params.setDescription(StringHelper.containsNonWhitespace(description) ? description : null);
  params.setOwnerName(StringHelper.containsNonWhitespace(ownerName) ? ownerName : null);
  params.setOwner(event.isOwner());
  params.setAttendee(event.isAttendee());
  params.setWaiting(event.isWaiting());
  params.setPublicGroup(event.isPublicGroups());
  params.setIdentity(getIdentity());
  List<BusinessGroup> groups;
  if (admin) {
    if (event.isAttendee() || event.isOwner()) {
      params.setIdentity(getIdentity());
    }
    groups=businessGroupService.findBusinessGroups(params,null,0,-1);
  }
 else {
    if (!event.isAttendee() && !event.isOwner() && !event.isWaiting()&& !event.isPublicGroups()) {
      params.setPublicGroup(true);
    }
    groups=businessGroupService.findBusinessGroups(params,null,0,-1);
  }
  List<Long> groupsWithMembership=businessGroupService.isIdentityInBusinessGroups(getIdentity(),groups);
  Set<Long> memberships=new HashSet<Long>(groupsWithMembership);
  List<Long> resourceKeys=new ArrayList<Long>();
  for (  BusinessGroup group : groups) {
    resourceKeys.add(group.getResource().getKey());
  }
  List<BGRepositoryEntryRelation> resources=businessGroupService.findRelationToRepositoryEntries(groups,0,-1);
  List<OLATResourceAccess> resourcesWithAC=acFrontendManager.getAccessMethodForResources(resourceKeys,true,new Date());
  List<BGTableItem> items=new ArrayList<BGTableItem>();
  for (  BusinessGroup group : groups) {
    Long oresKey=group.getResource().getKey();
    List<PriceMethodBundle> accessMethods=null;
    for (    OLATResourceAccess access : resourcesWithAC) {
      if (oresKey.equals(access.getResource().getKey())) {
        accessMethods=access.getMethods();
        break;
      }
    }
    Boolean allowLeave=memberships.contains(group.getKey()) ? Boolean.TRUE : null;
    Boolean allowDelete=admin ? Boolean.TRUE : null;
    boolean accessControl=(accessMethods != null);
    boolean member=memberships.contains(group.getKey());
    List<BGRepositoryEntryRelation> relations=new ArrayList<BGRepositoryEntryRelation>();
    for (    BGRepositoryEntryRelation resource : resources) {
      if (group.getKey().equals(resource.getGroupKey())) {
        relations.add(resource);
        if (relations.size() >= 3) {
          break;
        }
      }
    }
    BGTableItem tableItem=new BGTableItem(group,member,allowLeave,allowDelete,accessControl,accessMethods);
    tableItem.setRelations(relations);
    items.add(tableItem);
  }
  return items;
}