Program: 89167
Project: 89167
Buggy source:
@Override public List<? extends PortForwardingRule> listPortForwardingRules(ListPortForwardingRulesCmd 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(PortForwardingRuleVO.class,"String_Node_Str",false,cmd.getStartIndex(),cmd.getPageSizeVal());
  SearchBuilder<PortForwardingRuleVO> sb=_portForwardingDao.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<PortForwardingRuleVO> 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.PortForwarding);
  return _portForwardingDao.search(sc,filter);
}

Fixed version (ground truth):
@Override public List<? extends PortForwardingRule> listPortForwardingRules(ListPortForwardingRulesCmd 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(PortForwardingRuleVO.class,"String_Node_Str",false,cmd.getStartIndex(),cmd.getPageSizeVal());
  SearchBuilder<PortForwardingRuleVO> sb=_portForwardingDao.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<PortForwardingRuleVO> 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.PortForwarding);
  return _portForwardingDao.search(sc,filter);
}