Program: 106545
Project: 106545
Buggy source:
@Override public List<LoadBalancerVO> searchForLoadBalancers(ListLoadBalancerRulesCmd cmd){
  Long ipId=cmd.getPublicIpId();
  Long zoneId=cmd.getZoneId();
  Long id=cmd.getId();
  String name=cmd.getLoadBalancerRuleName();
  String keyword=cmd.getKeyword();
  Long instanceId=cmd.getVirtualMachineId();
  Account caller=UserContext.current().getCaller();
  List<Long> permittedAccounts=new ArrayList<Long>();
  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(LoadBalancerVO.class,"String_Node_Str",true,cmd.getStartIndex(),cmd.getPageSizeVal());
  SearchBuilder<LoadBalancerVO> sb=_lbDao.createSearchBuilder();
  _accountMgr.buildACLSearchBuilder(sb,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sb.and("String_Node_Str",sb.entity().getId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getName(),SearchCriteria.Op.LIKE);
  sb.and("String_Node_Str",sb.entity().getSourceIpAddressId(),SearchCriteria.Op.EQ);
  if (instanceId != null) {
    SearchBuilder<LoadBalancerVMMapVO> lbVMSearch=_lb2VmMapDao.createSearchBuilder();
    lbVMSearch.and("String_Node_Str",lbVMSearch.entity().getInstanceId(),SearchCriteria.Op.EQ);
    sb.join("String_Node_Str",lbVMSearch,sb.entity().getId(),lbVMSearch.entity().getLoadBalancerId(),JoinBuilder.JoinType.INNER);
  }
  if (zoneId != null) {
    SearchBuilder<IPAddressVO> ipSearch=_ipAddressDao.createSearchBuilder();
    ipSearch.and("String_Node_Str",ipSearch.entity().getDataCenterId(),SearchCriteria.Op.EQ);
    sb.join("String_Node_Str",ipSearch,sb.entity().getSourceIpAddressId(),ipSearch.entity().getId(),JoinBuilder.JoinType.INNER);
  }
  SearchCriteria<LoadBalancerVO> sc=sb.create();
  _accountMgr.buildACLSearchCriteria(sc,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  if (keyword != null) {
    SearchCriteria<LoadBalancerVO> ssc=_lbDao.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");
  }
  if (id != null) {
    sc.setParameters("String_Node_Str",id);
  }
  if (ipId != null) {
    sc.setParameters("String_Node_Str",ipId);
  }
  if (instanceId != null) {
    sc.setJoinParameters("String_Node_Str","String_Node_Str",instanceId);
  }
  if (zoneId != null) {
    sc.setJoinParameters("String_Node_Str","String_Node_Str",zoneId);
  }
  return _lbDao.search(sc,searchFilter);
}

Fixed version (ground truth):
@Override public List<LoadBalancerVO> searchForLoadBalancers(ListLoadBalancerRulesCmd cmd){
  Long ipId=cmd.getPublicIpId();
  Long zoneId=cmd.getZoneId();
  Long id=cmd.getId();
  String name=cmd.getLoadBalancerRuleName();
  String keyword=cmd.getKeyword();
  Long instanceId=cmd.getVirtualMachineId();
  Account caller=UserContext.current().getCaller();
  List<Long> permittedAccounts=new ArrayList<Long>();
  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(LoadBalancerVO.class,"String_Node_Str",true,cmd.getStartIndex(),cmd.getPageSizeVal());
  SearchBuilder<LoadBalancerVO> sb=_lbDao.createSearchBuilder();
  _accountMgr.buildACLSearchBuilder(sb,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sb.and("String_Node_Str",sb.entity().getId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getName(),SearchCriteria.Op.LIKE);
  sb.and("String_Node_Str",sb.entity().getSourceIpAddressId(),SearchCriteria.Op.EQ);
  if (instanceId != null) {
    SearchBuilder<LoadBalancerVMMapVO> lbVMSearch=_lb2VmMapDao.createSearchBuilder();
    lbVMSearch.and("String_Node_Str",lbVMSearch.entity().getInstanceId(),SearchCriteria.Op.EQ);
    sb.join("String_Node_Str",lbVMSearch,sb.entity().getId(),lbVMSearch.entity().getLoadBalancerId(),JoinBuilder.JoinType.INNER);
  }
  if (zoneId != null) {
    SearchBuilder<IPAddressVO> ipSearch=_ipAddressDao.createSearchBuilder();
    ipSearch.and("String_Node_Str",ipSearch.entity().getDataCenterId(),SearchCriteria.Op.EQ);
    sb.join("String_Node_Str",ipSearch,sb.entity().getSourceIpAddressId(),ipSearch.entity().getId(),JoinBuilder.JoinType.INNER);
  }
  SearchCriteria<LoadBalancerVO> sc=sb.create();
  _accountMgr.buildACLSearchCriteria(sc,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  if (keyword != null) {
    SearchCriteria<LoadBalancerVO> ssc=_lbDao.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");
  }
  if (id != null) {
    sc.setParameters("String_Node_Str",id);
  }
  if (ipId != null) {
    sc.setParameters("String_Node_Str",ipId);
  }
  if (instanceId != null) {
    sc.setJoinParameters("String_Node_Str","String_Node_Str",instanceId);
  }
  if (zoneId != null) {
    sc.setJoinParameters("String_Node_Str","String_Node_Str",zoneId);
  }
  return _lbDao.search(sc,searchFilter);
}