Program: 106546
Project: 106546
Buggy source:
@Override public List<? extends FirewallRule> searchStaticNatRules(Long ipId,Long id,Long vmId,Long start,Long size,String accountName,Long domainId,Long projectId,boolean isRecursive,boolean listAll){
  Account caller=UserContext.current().getCaller();
  List<Long> permittedAccounts=new ArrayList<Long>();
  if (ipId != null) {
    IPAddressVO ipAddressVO=_ipAddressDao.findById(ipId);
    if (ipAddressVO == null || !ipAddressVO.readyToUse()) {
      throw new InvalidParameterValueException("String_Node_Str" + ipId + "String_Node_Str");
    }
    _accountMgr.checkAccess(caller,null,true,ipAddressVO);
  }
  Ternary<Long,Boolean,ListProjectResourcesCriteria> domainIdRecursiveListProject=new Ternary<Long,Boolean,ListProjectResourcesCriteria>(domainId,isRecursive,null);
  _accountMgr.buildACLSearchParameters(caller,id,accountName,projectId,permittedAccounts,domainIdRecursiveListProject,listAll);
  domainId=domainIdRecursiveListProject.first();
  isRecursive=domainIdRecursiveListProject.second();
  ListProjectResourcesCriteria listProjectResourcesCriteria=domainIdRecursiveListProject.third();
  Filter filter=new Filter(PortForwardingRuleVO.class,"String_Node_Str",false,start,size);
  SearchBuilder<FirewallRuleVO> sb=_firewallDao.createSearchBuilder();
  _accountMgr.buildACLSearchBuilder(sb,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sb.and("String_Node_Str",sb.entity().getSourceIpAddressId(),Op.EQ);
  sb.and("String_Node_Str",sb.entity().getPurpose(),Op.EQ);
  sb.and("String_Node_Str",sb.entity().getId(),Op.EQ);
  if (vmId != null) {
    SearchBuilder<IPAddressVO> ipSearch=_ipAddressDao.createSearchBuilder();
    ipSearch.and("String_Node_Str",ipSearch.entity().getAssociatedWithVmId(),Op.EQ);
    sb.join("String_Node_Str",ipSearch,sb.entity().getSourceIpAddressId(),ipSearch.entity().getId(),JoinBuilder.JoinType.INNER);
  }
  SearchCriteria<FirewallRuleVO> sc=sb.create();
  _accountMgr.buildACLSearchCriteria(sc,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sc.setParameters("String_Node_Str",Purpose.StaticNat);
  if (id != null) {
    sc.setParameters("String_Node_Str",id);
  }
  if (ipId != null) {
    sc.setParameters("String_Node_Str",ipId);
  }
  if (vmId != null) {
    sc.setJoinParameters("String_Node_Str","String_Node_Str",vmId);
  }
  return _firewallDao.search(sc,filter);
}

Fixed version (ground truth):
@Override public List<? extends FirewallRule> searchStaticNatRules(Long ipId,Long id,Long vmId,Long start,Long size,String accountName,Long domainId,Long projectId,boolean isRecursive,boolean listAll){
  Account caller=UserContext.current().getCaller();
  List<Long> permittedAccounts=new ArrayList<Long>();
  if (ipId != null) {
    IPAddressVO ipAddressVO=_ipAddressDao.findById(ipId);
    if (ipAddressVO == null || !ipAddressVO.readyToUse()) {
      throw new InvalidParameterValueException("String_Node_Str" + ipId + "String_Node_Str");
    }
    _accountMgr.checkAccess(caller,null,true,ipAddressVO);
  }
  Ternary<Long,Boolean,ListProjectResourcesCriteria> domainIdRecursiveListProject=new Ternary<Long,Boolean,ListProjectResourcesCriteria>(domainId,isRecursive,null);
  _accountMgr.buildACLSearchParameters(caller,id,accountName,projectId,permittedAccounts,domainIdRecursiveListProject,listAll,false);
  domainId=domainIdRecursiveListProject.first();
  isRecursive=domainIdRecursiveListProject.second();
  ListProjectResourcesCriteria listProjectResourcesCriteria=domainIdRecursiveListProject.third();
  Filter filter=new Filter(PortForwardingRuleVO.class,"String_Node_Str",false,start,size);
  SearchBuilder<FirewallRuleVO> sb=_firewallDao.createSearchBuilder();
  _accountMgr.buildACLSearchBuilder(sb,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sb.and("String_Node_Str",sb.entity().getSourceIpAddressId(),Op.EQ);
  sb.and("String_Node_Str",sb.entity().getPurpose(),Op.EQ);
  sb.and("String_Node_Str",sb.entity().getId(),Op.EQ);
  if (vmId != null) {
    SearchBuilder<IPAddressVO> ipSearch=_ipAddressDao.createSearchBuilder();
    ipSearch.and("String_Node_Str",ipSearch.entity().getAssociatedWithVmId(),Op.EQ);
    sb.join("String_Node_Str",ipSearch,sb.entity().getSourceIpAddressId(),ipSearch.entity().getId(),JoinBuilder.JoinType.INNER);
  }
  SearchCriteria<FirewallRuleVO> sc=sb.create();
  _accountMgr.buildACLSearchCriteria(sc,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sc.setParameters("String_Node_Str",Purpose.StaticNat);
  if (id != null) {
    sc.setParameters("String_Node_Str",id);
  }
  if (ipId != null) {
    sc.setParameters("String_Node_Str",ipId);
  }
  if (vmId != null) {
    sc.setJoinParameters("String_Node_Str","String_Node_Str",vmId);
  }
  return _firewallDao.search(sc,filter);
}