Program: 106369
Project: 106369
Buggy source:
private Pair<List<StoragePoolJoinVO>,Integer> searchForStoragePoolsInternal(ListStoragePoolsCmd cmd){
  Long zoneId=_accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(),cmd.getZoneId());
  Object id=cmd.getId();
  Object name=cmd.getStoragePoolName();
  Object path=cmd.getPath();
  Object pod=cmd.getPodId();
  Object cluster=cmd.getClusterId();
  Object address=cmd.getIpAddress();
  Object keyword=cmd.getKeyword();
  Long startIndex=cmd.getStartIndex();
  Long pageSize=cmd.getPageSizeVal();
  Filter searchFilter=new Filter(StoragePoolJoinVO.class,"String_Node_Str",Boolean.TRUE,startIndex,pageSize);
  SearchBuilder<StoragePoolJoinVO> sb=_poolJoinDao.createSearchBuilder();
  sb.select(null,Func.DISTINCT,sb.entity().getId());
  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().getPath(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getZoneId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getPodId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getClusterId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getHostAddress(),SearchCriteria.Op.EQ);
  SearchCriteria<StoragePoolJoinVO> sc=sb.create();
  if (keyword != null) {
    SearchCriteria<StoragePoolJoinVO> ssc=_poolJoinDao.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 (id != null) {
    sc.setParameters("String_Node_Str",id);
  }
  if (name != null) {
    sc.setParameters("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + name + "String_Node_Str");
  }
  if (path != null) {
    sc.setParameters("String_Node_Str",SearchCriteria.Op.EQ,path);
  }
  if (zoneId != null) {
    sc.setParameters("String_Node_Str",SearchCriteria.Op.EQ,zoneId);
  }
  if (pod != null) {
    sc.setParameters("String_Node_Str",SearchCriteria.Op.EQ,pod);
  }
  if (address != null) {
    sc.setParameters("String_Node_Str",SearchCriteria.Op.EQ,address);
  }
  if (cluster != null) {
    sc.setParameters("String_Node_Str",SearchCriteria.Op.EQ,cluster);
  }
  Pair<List<StoragePoolJoinVO>,Integer> uniquePoolPair=_poolJoinDao.searchAndCount(sc,searchFilter);
  Integer count=uniquePoolPair.second();
  if (count.intValue() == 0) {
    return uniquePoolPair;
  }
  List<StoragePoolJoinVO> uniquePools=uniquePoolPair.first();
  Long[] vrIds=new Long[uniquePools.size()];
  int i=0;
  for (  StoragePoolJoinVO v : uniquePools) {
    vrIds[i++]=v.getId();
  }
  List<StoragePoolJoinVO> vrs=_poolJoinDao.searchByIds(vrIds);
  return new Pair<List<StoragePoolJoinVO>,Integer>(vrs,count);
}

Fixed version (ground truth):
private Pair<List<StoragePoolJoinVO>,Integer> searchForStoragePoolsInternal(ListStoragePoolsCmd cmd){
  Long zoneId=_accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(),cmd.getZoneId());
  Object id=cmd.getId();
  Object name=cmd.getStoragePoolName();
  Object path=cmd.getPath();
  Object pod=cmd.getPodId();
  Object cluster=cmd.getClusterId();
  Object address=cmd.getIpAddress();
  Object keyword=cmd.getKeyword();
  Long startIndex=cmd.getStartIndex();
  Long pageSize=cmd.getPageSizeVal();
  Filter searchFilter=new Filter(StoragePoolJoinVO.class,"String_Node_Str",Boolean.TRUE,startIndex,pageSize);
  SearchBuilder<StoragePoolJoinVO> sb=_poolJoinDao.createSearchBuilder();
  sb.select(null,Func.DISTINCT,sb.entity().getId());
  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().getPath(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getZoneId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getPodId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getClusterId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getHostAddress(),SearchCriteria.Op.EQ);
  SearchCriteria<StoragePoolJoinVO> sc=sb.create();
  if (keyword != null) {
    SearchCriteria<StoragePoolJoinVO> ssc=_poolJoinDao.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 (id != null) {
    sc.setParameters("String_Node_Str",id);
  }
  if (name != null) {
    sc.setParameters("String_Node_Str","String_Node_Str" + name + "String_Node_Str");
  }
  if (path != null) {
    sc.setParameters("String_Node_Str",path);
  }
  if (zoneId != null) {
    sc.setParameters("String_Node_Str",zoneId);
  }
  if (pod != null) {
    sc.setParameters("String_Node_Str",pod);
  }
  if (address != null) {
    sc.setParameters("String_Node_Str",address);
  }
  if (cluster != null) {
    sc.setParameters("String_Node_Str",cluster);
  }
  Pair<List<StoragePoolJoinVO>,Integer> uniquePoolPair=_poolJoinDao.searchAndCount(sc,searchFilter);
  Integer count=uniquePoolPair.second();
  if (count.intValue() == 0) {
    return uniquePoolPair;
  }
  List<StoragePoolJoinVO> uniquePools=uniquePoolPair.first();
  Long[] vrIds=new Long[uniquePools.size()];
  int i=0;
  for (  StoragePoolJoinVO v : uniquePools) {
    vrIds[i++]=v.getId();
  }
  List<StoragePoolJoinVO> vrs=_poolJoinDao.searchByIds(vrIds);
  return new Pair<List<StoragePoolJoinVO>,Integer>(vrs,count);
}