Program: 106265
Project: 106265
Buggy source:
private Pair<List<ImageStoreJoinVO>,Integer> searchForImageStoresInternal(ListImageStoresCmd cmd){
  Long zoneId=_accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(),cmd.getZoneId());
  Object id=cmd.getId();
  Object name=cmd.getStoreName();
  String provider=cmd.getProvider();
  String protocol=cmd.getProtocol();
  Object keyword=cmd.getKeyword();
  Long startIndex=cmd.getStartIndex();
  Long pageSize=cmd.getPageSizeVal();
  Filter searchFilter=new Filter(ImageStoreJoinVO.class,"String_Node_Str",Boolean.TRUE,startIndex,pageSize);
  SearchBuilder<ImageStoreJoinVO> sb=_imageStoreJoinDao.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.EQ);
  sb.and("String_Node_Str",sb.entity().getZoneId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getProtocol(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getProviderName(),SearchCriteria.Op.EQ);
  SearchCriteria<ImageStoreJoinVO> sc=sb.create();
  if (keyword != null) {
    SearchCriteria<ImageStoreJoinVO> ssc=_imageStoreJoinDao.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",name);
  }
  if (zoneId != null) {
    sc.setParameters("String_Node_Str",zoneId);
  }
  if (provider != null) {
    sc.setParameters("String_Node_Str",provider);
  }
  if (protocol != null) {
    sc.setParameters("String_Node_Str",protocol);
  }
  Pair<List<ImageStoreJoinVO>,Integer> uniqueStorePair=_imageStoreJoinDao.searchAndCount(sc,searchFilter);
  Integer count=uniqueStorePair.second();
  if (count.intValue() == 0) {
    return uniqueStorePair;
  }
  List<ImageStoreJoinVO> uniqueStores=uniqueStorePair.first();
  Long[] vrIds=new Long[uniqueStores.size()];
  int i=0;
  for (  ImageStoreJoinVO v : uniqueStores) {
    vrIds[i++]=v.getId();
  }
  List<ImageStoreJoinVO> vrs=_imageStoreJoinDao.searchByIds(vrIds);
  return new Pair<List<ImageStoreJoinVO>,Integer>(vrs,count);
}

Fixed version (ground truth):
private Pair<List<ImageStoreJoinVO>,Integer> searchForImageStoresInternal(ListImageStoresCmd cmd){
  Long zoneId=_accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(),cmd.getZoneId());
  Object id=cmd.getId();
  Object name=cmd.getStoreName();
  String provider=cmd.getProvider();
  String protocol=cmd.getProtocol();
  Object keyword=cmd.getKeyword();
  Long startIndex=cmd.getStartIndex();
  Long pageSize=cmd.getPageSizeVal();
  Filter searchFilter=new Filter(ImageStoreJoinVO.class,"String_Node_Str",Boolean.TRUE,startIndex,pageSize);
  SearchBuilder<ImageStoreJoinVO> sb=_imageStoreJoinDao.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.EQ);
  sb.and("String_Node_Str",sb.entity().getZoneId(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getProtocol(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getProviderName(),SearchCriteria.Op.EQ);
  sb.and("String_Node_Str",sb.entity().getRole(),SearchCriteria.Op.EQ);
  SearchCriteria<ImageStoreJoinVO> sc=sb.create();
  sc.setParameters("String_Node_Str",DataStoreRole.Image);
  if (keyword != null) {
    SearchCriteria<ImageStoreJoinVO> ssc=_imageStoreJoinDao.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",name);
  }
  if (zoneId != null) {
    sc.setParameters("String_Node_Str",zoneId);
  }
  if (provider != null) {
    sc.setParameters("String_Node_Str",provider);
  }
  if (protocol != null) {
    sc.setParameters("String_Node_Str",protocol);
  }
  Pair<List<ImageStoreJoinVO>,Integer> uniqueStorePair=_imageStoreJoinDao.searchAndCount(sc,searchFilter);
  Integer count=uniqueStorePair.second();
  if (count.intValue() == 0) {
    return uniqueStorePair;
  }
  List<ImageStoreJoinVO> uniqueStores=uniqueStorePair.first();
  Long[] vrIds=new Long[uniqueStores.size()];
  int i=0;
  for (  ImageStoreJoinVO v : uniqueStores) {
    vrIds[i++]=v.getId();
  }
  List<ImageStoreJoinVO> vrs=_imageStoreJoinDao.searchByIds(vrIds);
  return new Pair<List<ImageStoreJoinVO>,Integer>(vrs,count);
}