Program: 166375
Project: 166375
Buggy source:
private List<RangerPolicy.RangerPolicyItem> normalizeAndPrunePolicyItems(List<RangerPolicy.RangerPolicyItem> policyItems,final String componentType){
  if (CollectionUtils.isNotEmpty(policyItems)) {
    final String prefix=componentType + AbstractServiceStore.COMPONENT_ACCESSTYPE_SEPARATOR;
    List<RangerPolicy.RangerPolicyItem> itemsToPrune=null;
    for (    RangerPolicy.RangerPolicyItem policyItem : policyItems) {
      List<RangerPolicy.RangerPolicyItemAccess> policyItemAccesses=policyItem.getAccesses();
      if (CollectionUtils.isNotEmpty(policyItemAccesses)) {
        List<RangerPolicy.RangerPolicyItemAccess> accessesToPrune=null;
        for (        RangerPolicy.RangerPolicyItemAccess access : policyItemAccesses) {
          String accessType=access.getType();
          if (StringUtils.startsWith(accessType,prefix)) {
            String newAccessType=StringUtils.removeStart(accessType,prefix);
            access.setType(newAccessType);
          }
 else           if (accessType.contains(AbstractServiceStore.COMPONENT_ACCESSTYPE_SEPARATOR)) {
            if (accessesToPrune == null) {
              accessesToPrune=new ArrayList<RangerPolicy.RangerPolicyItemAccess>();
            }
            accessesToPrune.add(access);
          }
        }
        if (accessesToPrune != null) {
          policyItemAccesses.removeAll(accessesToPrune);
        }
        if (policyItemAccesses.isEmpty() && !policyItem.getDelegateAdmin()) {
          if (itemsToPrune != null) {
            itemsToPrune=new ArrayList<RangerPolicy.RangerPolicyItem>();
          }
          itemsToPrune.add(policyItem);
        }
      }
    }
    if (itemsToPrune != null) {
      policyItems.removeAll(itemsToPrune);
    }
  }
  return policyItems;
}

Fixed version (ground truth):
private List<RangerPolicy.RangerPolicyItem> normalizeAndPrunePolicyItems(List<RangerPolicy.RangerPolicyItem> policyItems,final String componentType){
  if (CollectionUtils.isNotEmpty(policyItems)) {
    final String prefix=componentType + AbstractServiceStore.COMPONENT_ACCESSTYPE_SEPARATOR;
    List<RangerPolicy.RangerPolicyItem> itemsToPrune=null;
    for (    RangerPolicy.RangerPolicyItem policyItem : policyItems) {
      List<RangerPolicy.RangerPolicyItemAccess> policyItemAccesses=policyItem.getAccesses();
      if (CollectionUtils.isNotEmpty(policyItemAccesses)) {
        List<RangerPolicy.RangerPolicyItemAccess> accessesToPrune=null;
        for (        RangerPolicy.RangerPolicyItemAccess access : policyItemAccesses) {
          String accessType=access.getType();
          if (StringUtils.startsWith(accessType,prefix)) {
            String newAccessType=StringUtils.removeStart(accessType,prefix);
            access.setType(newAccessType);
          }
 else           if (accessType.contains(AbstractServiceStore.COMPONENT_ACCESSTYPE_SEPARATOR)) {
            if (accessesToPrune == null) {
              accessesToPrune=new ArrayList<RangerPolicy.RangerPolicyItemAccess>();
            }
            accessesToPrune.add(access);
          }
        }
        if (accessesToPrune != null) {
          policyItemAccesses.removeAll(accessesToPrune);
        }
        if (policyItemAccesses.isEmpty() && !policyItem.getDelegateAdmin()) {
          if (itemsToPrune == null) {
            itemsToPrune=new ArrayList<RangerPolicy.RangerPolicyItem>();
          }
          itemsToPrune.add(policyItem);
        }
      }
    }
    if (itemsToPrune != null) {
      policyItems.removeAll(itemsToPrune);
    }
  }
  return policyItems;
}