Program: 106184
Project: 106184
Buggy source:
private Pair<List<UserVmJoinVO>,Integer> searchForUserVMsInternal(ListVMsCmd cmd){
  Account caller=CallContext.current().getCallingAccount();
  List<Long> permittedAccounts=new ArrayList<Long>();
  String hypervisor=cmd.getHypervisor();
  boolean listAll=cmd.listAll();
  Long id=cmd.getId();
  Map<String,String> tags=cmd.getTags();
  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,listAll,false);
  Long domainId=domainIdRecursiveListProject.first();
  Boolean isRecursive=domainIdRecursiveListProject.second();
  ListProjectResourcesCriteria listProjectResourcesCriteria=domainIdRecursiveListProject.third();
  Criteria c=new Criteria("String_Node_Str",Boolean.TRUE,cmd.getStartIndex(),cmd.getPageSizeVal());
  c.addCriteria(Criteria.KEYWORD,cmd.getKeyword());
  c.addCriteria(Criteria.ID,cmd.getId());
  c.addCriteria(Criteria.NAME,cmd.getInstanceName());
  c.addCriteria(Criteria.STATE,cmd.getState());
  c.addCriteria(Criteria.DATACENTERID,cmd.getZoneId());
  c.addCriteria(Criteria.GROUPID,cmd.getGroupId());
  c.addCriteria(Criteria.FOR_VIRTUAL_NETWORK,cmd.getForVirtualNetwork());
  c.addCriteria(Criteria.NETWORKID,cmd.getNetworkId());
  c.addCriteria(Criteria.TEMPLATE_ID,cmd.getTemplateId());
  c.addCriteria(Criteria.ISO_ID,cmd.getIsoId());
  c.addCriteria(Criteria.VPC_ID,cmd.getVpcId());
  c.addCriteria(Criteria.AFFINITY_GROUP_ID,cmd.getAffinityGroupId());
  if (domainId != null) {
    c.addCriteria(Criteria.DOMAINID,domainId);
  }
  if (HypervisorType.getType(hypervisor) != HypervisorType.None) {
    c.addCriteria(Criteria.HYPERVISOR,hypervisor);
  }
 else   if (hypervisor != null) {
    throw new InvalidParameterValueException("String_Node_Str" + hypervisor);
  }
  if (_accountMgr.isAdmin(caller.getType())) {
    c.addCriteria(Criteria.PODID,cmd.getPodId());
    c.addCriteria(Criteria.HOSTID,cmd.getHostId());
    c.addCriteria(Criteria.STORAGE_ID,cmd.getStorageId());
  }
  if (!permittedAccounts.isEmpty()) {
    c.addCriteria(Criteria.ACCOUNTID,permittedAccounts.toArray());
  }
  c.addCriteria(Criteria.ISADMIN,_accountMgr.isAdmin(caller.getType()));
  return searchForUserVMsByCriteria(c,caller,domainId,isRecursive,permittedAccounts,listAll,listProjectResourcesCriteria,tags);
}

Fixed version (ground truth):
private Pair<List<UserVmJoinVO>,Integer> searchForUserVMsInternal(ListVMsCmd cmd){
  Account caller=CallContext.current().getCallingAccount();
  List<Long> permittedAccounts=new ArrayList<Long>();
  String hypervisor=cmd.getHypervisor();
  boolean listAll=cmd.listAll();
  Long id=cmd.getId();
  Map<String,String> tags=cmd.getTags();
  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,listAll,false);
  Long domainId=domainIdRecursiveListProject.first();
  Boolean isRecursive=domainIdRecursiveListProject.second();
  ListProjectResourcesCriteria listProjectResourcesCriteria=domainIdRecursiveListProject.third();
  Criteria c=new Criteria("String_Node_Str",Boolean.TRUE,cmd.getStartIndex(),cmd.getPageSizeVal());
  c.addCriteria(Criteria.KEYWORD,cmd.getKeyword());
  c.addCriteria(Criteria.ID,cmd.getId());
  c.addCriteria(Criteria.NAME,cmd.getName());
  c.addCriteria(Criteria.STATE,cmd.getState());
  c.addCriteria(Criteria.DATACENTERID,cmd.getZoneId());
  c.addCriteria(Criteria.GROUPID,cmd.getGroupId());
  c.addCriteria(Criteria.FOR_VIRTUAL_NETWORK,cmd.getForVirtualNetwork());
  c.addCriteria(Criteria.NETWORKID,cmd.getNetworkId());
  c.addCriteria(Criteria.TEMPLATE_ID,cmd.getTemplateId());
  c.addCriteria(Criteria.ISO_ID,cmd.getIsoId());
  c.addCriteria(Criteria.VPC_ID,cmd.getVpcId());
  c.addCriteria(Criteria.AFFINITY_GROUP_ID,cmd.getAffinityGroupId());
  if (domainId != null) {
    c.addCriteria(Criteria.DOMAINID,domainId);
  }
  if (HypervisorType.getType(hypervisor) != HypervisorType.None) {
    c.addCriteria(Criteria.HYPERVISOR,hypervisor);
  }
 else   if (hypervisor != null) {
    throw new InvalidParameterValueException("String_Node_Str" + hypervisor);
  }
  if (_accountMgr.isAdmin(caller.getType())) {
    c.addCriteria(Criteria.PODID,cmd.getPodId());
    c.addCriteria(Criteria.HOSTID,cmd.getHostId());
    c.addCriteria(Criteria.STORAGE_ID,cmd.getStorageId());
  }
  if (!permittedAccounts.isEmpty()) {
    c.addCriteria(Criteria.ACCOUNTID,permittedAccounts.toArray());
  }
  c.addCriteria(Criteria.ISADMIN,_accountMgr.isAdmin(caller.getType()));
  return searchForUserVMsByCriteria(c,caller,domainId,isRecursive,permittedAccounts,listAll,listProjectResourcesCriteria,tags);
}