Program: 166216
Project: 166216
Buggy source:
public VXPolicyList rangerPolicyListToPublic(List<RangerPolicy> rangerPolicyList,SearchFilter filter){
  RangerService service=null;
  List<VXPolicy> vXPolicyList=new ArrayList<VXPolicy>();
  VXPolicyList vXPolicyListObj=new VXPolicyList(new ArrayList<VXPolicy>());
  if (CollectionUtils.isNotEmpty(rangerPolicyList)) {
    int totalCount=rangerPolicyList.size();
    int startIndex=filter == null ? 0 : filter.getStartIndex();
    int pageSize=filter == null ? totalCount : filter.getMaxRows();
    int toIndex=Math.min(startIndex + pageSize,totalCount);
    String sortType=filter == null ? null : filter.getSortType();
    String sortBy=filter == null ? null : filter.getSortBy();
    for (int i=startIndex; i < toIndex; i++) {
      RangerPolicy policy=rangerPolicyList.get(i);
      try {
        service=svcStore.getServiceByName(policy.getService());
      }
 catch (      Exception excp) {
        throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST,excp.getMessage(),true);
      }
      if (service == null) {
        throw restErrorUtil.createRESTException(HttpServletResponse.SC_NOT_FOUND,RangerServiceNotFoundException.buildExceptionMsg(policy.getService()),true);
      }
      VXPolicy vXPolicy=toVXPolicy(policy,service);
      if (vXPolicy != null) {
        vXPolicyList.add(vXPolicy);
      }
    }
    vXPolicyListObj=new VXPolicyList(vXPolicyList);
    vXPolicyListObj.setPageSize(pageSize);
    vXPolicyListObj.setResultSize(vXPolicyList.size());
    vXPolicyListObj.setStartIndex(startIndex);
    vXPolicyListObj.setTotalCount(totalCount);
    vXPolicyListObj.setSortBy(sortBy);
    vXPolicyListObj.setSortType(sortType);
  }
  return vXPolicyListObj;
}

Fixed version (ground truth):
public VXPolicyList rangerPolicyListToPublic(List<RangerPolicy> rangerPolicyList,SearchFilter filter){
  RangerService service=null;
  List<VXPolicy> vXPolicyList=new ArrayList<VXPolicy>();
  VXPolicyList vXPolicyListObj=new VXPolicyList(new ArrayList<VXPolicy>());
  if (CollectionUtils.isNotEmpty(rangerPolicyList)) {
    int totalCount=rangerPolicyList.size();
    int startIndex=filter.getStartIndex();
    int pageSize=filter.getMaxRows();
    int toIndex=Math.min(startIndex + pageSize,totalCount);
    String sortType=filter.getSortType();
    String sortBy=filter.getSortBy();
    for (int i=startIndex; i < toIndex; i++) {
      RangerPolicy policy=rangerPolicyList.get(i);
      try {
        service=svcStore.getServiceByName(policy.getService());
      }
 catch (      Exception excp) {
        throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST,excp.getMessage(),true);
      }
      if (service == null) {
        throw restErrorUtil.createRESTException(HttpServletResponse.SC_NOT_FOUND,RangerServiceNotFoundException.buildExceptionMsg(policy.getService()),true);
      }
      VXPolicy vXPolicy=toVXPolicy(policy,service);
      if (vXPolicy != null) {
        vXPolicyList.add(vXPolicy);
      }
    }
    vXPolicyListObj=new VXPolicyList(vXPolicyList);
    vXPolicyListObj.setPageSize(pageSize);
    vXPolicyListObj.setResultSize(vXPolicyList.size());
    vXPolicyListObj.setStartIndex(startIndex);
    vXPolicyListObj.setTotalCount(totalCount);
    vXPolicyListObj.setSortBy(sortBy);
    vXPolicyListObj.setSortType(sortType);
  }
  return vXPolicyListObj;
}