Program: 89164
Project: 89164
Buggy source:
@Override public List<? extends FirewallRule> listFirewallRules(ListFirewallRulesCmd cmd){
  Long ipId=cmd.getIpAddressId();
  Long id=cmd.getId();
  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>(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 filter=new Filter(FirewallRuleVO.class,"String_Node_Str",false,cmd.getStartIndex(),cmd.getPageSizeVal());
  SearchBuilder<FirewallRuleVO> sb=_firewallDao.createSearchBuilder();
  _accountMgr.buildACLSearchBuilder(sb,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sb.and("String_Node_Str",sb.entity().getId(),Op.EQ);
  sb.and("String_Node_Str",sb.entity().getSourceIpAddressId(),Op.EQ);
  sb.and("String_Node_Str",sb.entity().getPurpose(),Op.EQ);
  SearchCriteria<FirewallRuleVO> sc=sb.create();
  _accountMgr.buildACLSearchCriteria(sc,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  if (id != null) {
    sc.setParameters("String_Node_Str",id);
  }
  if (ipId != null) {
    sc.setParameters("String_Node_Str",ipId);
  }
  sc.setParameters("String_Node_Str",Purpose.Firewall);
  return _firewallDao.search(sc,filter);
}

Fixed version (ground truth):
@Override public List<? extends FirewallRule> listFirewallRules(ListFirewallRulesCmd cmd){
  Long ipId=cmd.getIpAddressId();
  Long id=cmd.getId();
  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>(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 filter=new Filter(FirewallRuleVO.class,"String_Node_Str",false,cmd.getStartIndex(),cmd.getPageSizeVal());
  SearchBuilder<FirewallRuleVO> sb=_firewallDao.createSearchBuilder();
  _accountMgr.buildACLSearchBuilder(sb,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sb.and("String_Node_Str",sb.entity().getId(),Op.EQ);
  sb.and("String_Node_Str",sb.entity().getSourceIpAddressId(),Op.EQ);
  sb.and("String_Node_Str",sb.entity().getPurpose(),Op.EQ);
  SearchCriteria<FirewallRuleVO> sc=sb.create();
  _accountMgr.buildACLSearchCriteria(sc,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  if (id != null) {
    sc.setParameters("String_Node_Str",id);
  }
  if (ipId != null) {
    sc.setParameters("String_Node_Str",ipId);
  }
  sc.setParameters("String_Node_Str",Purpose.Firewall);
  return _firewallDao.search(sc,filter);
}