Program: 106314
Project: 106314
Buggy source:
@Override protected List<StoragePool> select(DiskProfile dskCh,VirtualMachineProfile<? extends VirtualMachine> vmProfile,DeploymentPlan plan,ExcludeList avoid,int returnUpTo){
  List<StoragePool> suitablePools=new ArrayList<StoragePool>();
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str");
  }
  if (dskCh.getType() == Volume.Type.DATADISK && plan.getHostId() != null) {
    List<StoragePoolHostVO> hostPools=_poolHostDao.listByHostId(plan.getHostId());
    for (    StoragePoolHostVO hostPool : hostPools) {
      StoragePoolVO pool=_storagePoolDao.findById(hostPool.getPoolId());
      if (pool != null && pool.isLocal()) {
        StoragePool pol=(StoragePool)this.dataStoreMgr.getPrimaryDataStore(pool.getId());
        if (filter(avoid,pol,dskCh,plan)) {
          s_logger.debug("String_Node_Str" + pool.getId() + "String_Node_Str");
          suitablePools.add(pol);
        }
      }
      if (suitablePools.size() == returnUpTo) {
        break;
      }
    }
  }
 else {
    List<StoragePoolVO> availablePools=_storagePoolDao.findLocalStoragePoolsByTags(plan.getDataCenterId(),plan.getPodId(),plan.getClusterId(),dskCh.getTags());
    for (    StoragePoolVO pool : availablePools) {
      if (suitablePools.size() == returnUpTo) {
        break;
      }
      StoragePool pol=(StoragePool)this.dataStoreMgr.getPrimaryDataStore(pool.getId());
      if (filter(avoid,pol,dskCh,plan)) {
        suitablePools.add(pol);
      }
    }
  }
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + suitablePools.size() + "String_Node_Str");
  }
  return suitablePools;
}

Fixed version (ground truth):
@Override protected List<StoragePool> select(DiskProfile dskCh,VirtualMachineProfile<? extends VirtualMachine> vmProfile,DeploymentPlan plan,ExcludeList avoid,int returnUpTo){
  List<StoragePool> suitablePools=new ArrayList<StoragePool>();
  s_logger.debug("String_Node_Str");
  if (!dskCh.useLocalStorage()) {
    return suitablePools;
  }
  if (dskCh.getType() == Volume.Type.DATADISK && plan.getHostId() != null) {
    List<StoragePoolHostVO> hostPools=_poolHostDao.listByHostId(plan.getHostId());
    for (    StoragePoolHostVO hostPool : hostPools) {
      StoragePoolVO pool=_storagePoolDao.findById(hostPool.getPoolId());
      if (pool != null && pool.isLocal()) {
        StoragePool pol=(StoragePool)this.dataStoreMgr.getPrimaryDataStore(pool.getId());
        if (filter(avoid,pol,dskCh,plan)) {
          s_logger.debug("String_Node_Str" + pool.getId() + "String_Node_Str");
          suitablePools.add(pol);
        }
      }
      if (suitablePools.size() == returnUpTo) {
        break;
      }
    }
  }
 else {
    List<StoragePoolVO> availablePools=_storagePoolDao.findLocalStoragePoolsByTags(plan.getDataCenterId(),plan.getPodId(),plan.getClusterId(),dskCh.getTags());
    for (    StoragePoolVO pool : availablePools) {
      if (suitablePools.size() == returnUpTo) {
        break;
      }
      StoragePool pol=(StoragePool)this.dataStoreMgr.getPrimaryDataStore(pool.getId());
      if (filter(avoid,pol,dskCh,plan)) {
        suitablePools.add(pol);
      }
    }
  }
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + suitablePools.size() + "String_Node_Str");
  }
  return suitablePools;
}