Program: 89179
Project: 89179
Buggy source:
@Override public List<VolumeVO> searchForVolumes(ListVolumesCmd cmd){
  Account caller=UserContext.current().getCaller();
  List<Long> permittedAccounts=new ArrayList<Long>();
  Long id=cmd.getId();
  Long vmInstanceId=cmd.getVirtualMachineId();
  String name=cmd.getVolumeName();
  String keyword=cmd.getKeyword();
  String type=cmd.getType();
  Long zoneId=cmd.getZoneId();
  Long podId=null;
  if (_accountMgr.isAdmin(caller.getType())) {
    podId=cmd.getPodId();
  }
  Ternary<Long,Boolean,ListProjectResourcesCriteria> domainIdRecursiveListProject=new Ternary<Long,Boolean,ListProjectResourcesCriteria>(cmd.getDomainId(),cmd.isRecursive(),null);
  _accountMgr.buildACLSearchParameters(caller,id,cmd.getAccountName(),cmd.getProjectId(),permittedAccounts,domainIdRecursiveListProject,cmd.listAll());
  Long domainId=domainIdRecursiveListProject.first();
  Boolean isRecursive=domainIdRecursiveListProject.second();
  ListProjectResourcesCriteria listProjectResourcesCriteria=domainIdRecursiveListProject.third();
  Filter searchFilter=new Filter(VolumeVO.class,"String_Node_Str",false,cmd.getStartIndex(),cmd.getPageSizeVal());
  SearchBuilder<VolumeVO> sb=_volumeDao.createSearchBuilder();
  _accountMgr.buildACLSearchBuilder(sb,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sb.and("String_Node_Str",sb.entity().getName(),SearchCriteria.Op.LIKE);
  sb.and("String_Node_Str",sb.entity().getId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getVolumeType(),SearchCriteria.Op.LIKE);
  sb.and("String_Node_Str",sb.entity().getInstanceId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getDataCenterId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getPodId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getState(),SearchCriteria.Op.NEQ);
  SearchBuilder<DiskOfferingVO> diskOfferingSearch=_diskOfferingDao.createSearchBuilder();
  diskOfferingSearch.and("String_Node_Str",diskOfferingSearch.entity().getSystemUse(),SearchCriteria.Op.NEQ);
  sb.join("String_Node_Str",diskOfferingSearch,sb.entity().getDiskOfferingId(),diskOfferingSearch.entity().getId(),JoinBuilder.JoinType.LEFTOUTER);
  SearchBuilder<VMInstanceVO> vmSearch=_vmInstanceDao.createSearchBuilder();
  vmSearch.and("String_Node_Str",vmSearch.entity().getType(),SearchCriteria.Op.NIN);
  vmSearch.or("String_Node_Str",vmSearch.entity().getType(),SearchCriteria.Op.NULL);
  sb.join("String_Node_Str",vmSearch,sb.entity().getInstanceId(),vmSearch.entity().getId(),JoinBuilder.JoinType.LEFTOUTER);
  SearchCriteria<VolumeVO> sc=sb.create();
  _accountMgr.buildACLSearchCriteria(sc,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  if (keyword != null) {
    SearchCriteria<VolumeVO> ssc=_volumeDao.createSearchCriteria();
    ssc.addOr("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + keyword + "String_Node_Str");
    ssc.addOr("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + keyword + "String_Node_Str");
    sc.addAnd("String_Node_Str",SearchCriteria.Op.SC,ssc);
  }
  if (name != null) {
    sc.setParameters("String_Node_Str","String_Node_Str" + name + "String_Node_Str");
  }
  sc.setJoinParameters("String_Node_Str","String_Node_Str",1);
  if (id != null) {
    sc.setParameters("String_Node_Str",id);
  }
  if (type != null) {
    sc.setParameters("String_Node_Str","String_Node_Str" + type + "String_Node_Str");
  }
  if (vmInstanceId != null) {
    sc.setParameters("String_Node_Str",vmInstanceId);
  }
  if (zoneId != null) {
    sc.setParameters("String_Node_Str",zoneId);
  }
  if (podId != null) {
    sc.setParameters("String_Node_Str",podId);
  }
  sc.setJoinParameters("String_Node_Str","String_Node_Str",VirtualMachine.Type.ConsoleProxy,VirtualMachine.Type.SecondaryStorageVm,VirtualMachine.Type.DomainRouter);
  sc.setParameters("String_Node_Str",Volume.State.Destroy);
  return _volumeDao.search(sc,searchFilter);
}

Fixed version (ground truth):
@Override public List<VolumeVO> searchForVolumes(ListVolumesCmd cmd){
  Account caller=UserContext.current().getCaller();
  List<Long> permittedAccounts=new ArrayList<Long>();
  Long id=cmd.getId();
  Long vmInstanceId=cmd.getVirtualMachineId();
  String name=cmd.getVolumeName();
  String keyword=cmd.getKeyword();
  String type=cmd.getType();
  Long zoneId=cmd.getZoneId();
  Long podId=null;
  if (_accountMgr.isAdmin(caller.getType())) {
    podId=cmd.getPodId();
  }
  Ternary<Long,Boolean,ListProjectResourcesCriteria> domainIdRecursiveListProject=new Ternary<Long,Boolean,ListProjectResourcesCriteria>(cmd.getDomainId(),cmd.isRecursive(),null);
  _accountMgr.buildACLSearchParameters(caller,id,cmd.getAccountName(),cmd.getProjectId(),permittedAccounts,domainIdRecursiveListProject,cmd.listAll(),false);
  Long domainId=domainIdRecursiveListProject.first();
  Boolean isRecursive=domainIdRecursiveListProject.second();
  ListProjectResourcesCriteria listProjectResourcesCriteria=domainIdRecursiveListProject.third();
  Filter searchFilter=new Filter(VolumeVO.class,"String_Node_Str",false,cmd.getStartIndex(),cmd.getPageSizeVal());
  SearchBuilder<VolumeVO> sb=_volumeDao.createSearchBuilder();
  _accountMgr.buildACLSearchBuilder(sb,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sb.and("String_Node_Str",sb.entity().getName(),SearchCriteria.Op.LIKE);
  sb.and("String_Node_Str",sb.entity().getId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getVolumeType(),SearchCriteria.Op.LIKE);
  sb.and("String_Node_Str",sb.entity().getInstanceId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getDataCenterId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getPodId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getState(),SearchCriteria.Op.NEQ);
  SearchBuilder<DiskOfferingVO> diskOfferingSearch=_diskOfferingDao.createSearchBuilder();
  diskOfferingSearch.and("String_Node_Str",diskOfferingSearch.entity().getSystemUse(),SearchCriteria.Op.NEQ);
  sb.join("String_Node_Str",diskOfferingSearch,sb.entity().getDiskOfferingId(),diskOfferingSearch.entity().getId(),JoinBuilder.JoinType.LEFTOUTER);
  SearchBuilder<VMInstanceVO> vmSearch=_vmInstanceDao.createSearchBuilder();
  vmSearch.and("String_Node_Str",vmSearch.entity().getType(),SearchCriteria.Op.NIN);
  vmSearch.or("String_Node_Str",vmSearch.entity().getType(),SearchCriteria.Op.NULL);
  sb.join("String_Node_Str",vmSearch,sb.entity().getInstanceId(),vmSearch.entity().getId(),JoinBuilder.JoinType.LEFTOUTER);
  SearchCriteria<VolumeVO> sc=sb.create();
  _accountMgr.buildACLSearchCriteria(sc,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  if (keyword != null) {
    SearchCriteria<VolumeVO> ssc=_volumeDao.createSearchCriteria();
    ssc.addOr("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + keyword + "String_Node_Str");
    ssc.addOr("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + keyword + "String_Node_Str");
    sc.addAnd("String_Node_Str",SearchCriteria.Op.SC,ssc);
  }
  if (name != null) {
    sc.setParameters("String_Node_Str","String_Node_Str" + name + "String_Node_Str");
  }
  sc.setJoinParameters("String_Node_Str","String_Node_Str",1);
  if (id != null) {
    sc.setParameters("String_Node_Str",id);
  }
  if (type != null) {
    sc.setParameters("String_Node_Str","String_Node_Str" + type + "String_Node_Str");
  }
  if (vmInstanceId != null) {
    sc.setParameters("String_Node_Str",vmInstanceId);
  }
  if (zoneId != null) {
    sc.setParameters("String_Node_Str",zoneId);
  }
  if (podId != null) {
    sc.setParameters("String_Node_Str",podId);
  }
  sc.setJoinParameters("String_Node_Str","String_Node_Str",VirtualMachine.Type.ConsoleProxy,VirtualMachine.Type.SecondaryStorageVm,VirtualMachine.Type.DomainRouter);
  sc.setParameters("String_Node_Str",Volume.State.Destroy);
  return _volumeDao.search(sc,searchFilter);
}