Program: 89170
Project: 89170
Buggy source:
@Override public List<VpnUserVO> searchForVpnUsers(ListVpnUsersCmd cmd){
  String username=cmd.getUsername();
  Long id=cmd.getId();
  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(VpnUserVO.class,"String_Node_Str",true,cmd.getStartIndex(),cmd.getPageSizeVal());
  SearchBuilder<VpnUserVO> sb=_vpnUsersDao.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().getUsername(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getState(),SearchCriteria.Op.EQ);
  SearchCriteria<VpnUserVO> sc=sb.create();
  _accountMgr.buildACLSearchCriteria(sc,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sc.setParameters("String_Node_Str",State.Active);
  if (id != null) {
    sc.setParameters("String_Node_Str",id);
  }
  if (username != null) {
    sc.setParameters("String_Node_Str",username);
  }
  return _vpnUsersDao.search(sc,searchFilter);
}

Fixed version (ground truth):
@Override public List<VpnUserVO> searchForVpnUsers(ListVpnUsersCmd cmd){
  String username=cmd.getUsername();
  Long id=cmd.getId();
  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(VpnUserVO.class,"String_Node_Str",true,cmd.getStartIndex(),cmd.getPageSizeVal());
  SearchBuilder<VpnUserVO> sb=_vpnUsersDao.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().getUsername(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getState(),SearchCriteria.Op.EQ);
  SearchCriteria<VpnUserVO> sc=sb.create();
  _accountMgr.buildACLSearchCriteria(sc,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sc.setParameters("String_Node_Str",State.Active);
  if (id != null) {
    sc.setParameters("String_Node_Str",id);
  }
  if (username != null) {
    sc.setParameters("String_Node_Str",username);
  }
  return _vpnUsersDao.search(sc,searchFilter);
}