Program: 89350
Project: 89350
Buggy source:
protected Pair<Map<Volume,List<StoragePool>>,List<Volume>> findSuitablePoolsForVolumes(VirtualMachineProfile<? extends VirtualMachine> vmProfile,DeploymentPlan plan,ExcludeList avoid,int returnUpTo){
  List<VolumeVO> volumesTobeCreated=_volsDao.findUsableVolumesForInstance(vmProfile.getId());
  Map<Volume,List<StoragePool>> suitableVolumeStoragePools=new HashMap<Volume,List<StoragePool>>();
  List<Volume> readyAndReusedVolumes=new ArrayList<Volume>();
  for (  VolumeVO toBeCreated : volumesTobeCreated) {
    s_logger.debug("String_Node_Str" + toBeCreated.getId() + "String_Node_Str"+ toBeCreated.getVolumeType().name()+ "String_Node_Str");
    if (plan.getPoolId() != null) {
      if (toBeCreated.getState() == Volume.State.Ready && toBeCreated.getPoolId() != null) {
        s_logger.debug("String_Node_Str" + toBeCreated.getPoolId());
        List<StoragePool> suitablePools=new ArrayList<StoragePool>();
        StoragePoolVO pool=_storagePoolDao.findById(toBeCreated.getPoolId());
        if (!pool.isInMaintenance()) {
          if (!avoid.shouldAvoid(pool)) {
            long exstPoolDcId=pool.getDataCenterId();
            Long exstPoolPodId=pool.getPodId();
            Long exstPoolClusterId=pool.getClusterId();
            if (plan.getDataCenterId() == exstPoolDcId && plan.getPodId() == exstPoolPodId && plan.getClusterId() == exstPoolClusterId) {
              s_logger.debug("String_Node_Str");
              suitablePools.add(pool);
              suitableVolumeStoragePools.put(toBeCreated,suitablePools);
              readyAndReusedVolumes.add(toBeCreated);
              continue;
            }
 else {
              s_logger.debug("String_Node_Str");
            }
          }
 else {
            s_logger.debug("String_Node_Str");
          }
        }
 else {
          s_logger.debug("String_Node_Str");
        }
      }
    }
    s_logger.debug("String_Node_Str");
    DiskOfferingVO diskOffering=_diskOfferingDao.findById(toBeCreated.getDiskOfferingId());
    DiskProfile diskProfile=new DiskProfile(toBeCreated,diskOffering,vmProfile.getHypervisorType());
    boolean useLocalStorage=false;
    if (vmProfile.getType() != VirtualMachine.Type.User) {
      String ssvmUseLocalStorage=_configDao.getValue(Config.SystemVMUseLocalStorage.key());
      if (ssvmUseLocalStorage.equalsIgnoreCase("String_Node_Str")) {
        useLocalStorage=true;
      }
    }
 else {
      useLocalStorage=diskOffering.getUseLocalStorage();
    }
    diskProfile.setUseLocalStorage(useLocalStorage);
    boolean foundPotentialPools=false;
    Enumeration<StoragePoolAllocator> enPool=_storagePoolAllocators.enumeration();
    while (enPool.hasMoreElements()) {
      final StoragePoolAllocator allocator=enPool.nextElement();
      final List<StoragePool> suitablePools=allocator.allocateToPool(diskProfile,vmProfile.getTemplate(),plan,avoid,returnUpTo);
      if (suitablePools != null && !suitablePools.isEmpty()) {
        suitableVolumeStoragePools.put(toBeCreated,suitablePools);
        foundPotentialPools=true;
        break;
      }
    }
    if (!foundPotentialPools) {
      s_logger.debug("String_Node_Str" + toBeCreated + "String_Node_Str"+ plan.getClusterId());
      suitableVolumeStoragePools.clear();
      break;
    }
  }
  if (suitableVolumeStoragePools.isEmpty()) {
    s_logger.debug("String_Node_Str");
  }
  return new Pair<Map<Volume,List<StoragePool>>,List<Volume>>(suitableVolumeStoragePools,readyAndReusedVolumes);
}

Fixed version (ground truth):
protected Pair<Map<Volume,List<StoragePool>>,List<Volume>> findSuitablePoolsForVolumes(VirtualMachineProfile<? extends VirtualMachine> vmProfile,DeploymentPlan plan,ExcludeList avoid,int returnUpTo){
  List<VolumeVO> volumesTobeCreated=_volsDao.findUsableVolumesForInstance(vmProfile.getId());
  Map<Volume,List<StoragePool>> suitableVolumeStoragePools=new HashMap<Volume,List<StoragePool>>();
  List<Volume> readyAndReusedVolumes=new ArrayList<Volume>();
  for (  VolumeVO toBeCreated : volumesTobeCreated) {
    s_logger.debug("String_Node_Str" + toBeCreated.getId() + "String_Node_Str"+ toBeCreated.getVolumeType().name()+ "String_Node_Str");
    if (plan.getPoolId() != null) {
      if (toBeCreated.getState() == Volume.State.Ready && toBeCreated.getPoolId() != null) {
        s_logger.debug("String_Node_Str" + toBeCreated.getPoolId());
        List<StoragePool> suitablePools=new ArrayList<StoragePool>();
        StoragePoolVO pool=_storagePoolDao.findById(toBeCreated.getPoolId());
        if (!pool.isInMaintenance()) {
          if (!avoid.shouldAvoid(pool)) {
            long exstPoolDcId=pool.getDataCenterId();
            long exstPoolPodId=pool.getPodId() != null ? pool.getPodId() : -1;
            long exstPoolClusterId=pool.getClusterId() != null ? pool.getClusterId() : -1;
            if (plan.getDataCenterId() == exstPoolDcId && plan.getPodId() == exstPoolPodId && plan.getClusterId() == exstPoolClusterId) {
              s_logger.debug("String_Node_Str");
              suitablePools.add(pool);
              suitableVolumeStoragePools.put(toBeCreated,suitablePools);
              readyAndReusedVolumes.add(toBeCreated);
              continue;
            }
 else {
              s_logger.debug("String_Node_Str");
            }
          }
 else {
            s_logger.debug("String_Node_Str");
          }
        }
 else {
          s_logger.debug("String_Node_Str");
        }
      }
    }
    s_logger.debug("String_Node_Str");
    DiskOfferingVO diskOffering=_diskOfferingDao.findById(toBeCreated.getDiskOfferingId());
    DiskProfile diskProfile=new DiskProfile(toBeCreated,diskOffering,vmProfile.getHypervisorType());
    boolean useLocalStorage=false;
    if (vmProfile.getType() != VirtualMachine.Type.User) {
      String ssvmUseLocalStorage=_configDao.getValue(Config.SystemVMUseLocalStorage.key());
      if (ssvmUseLocalStorage.equalsIgnoreCase("String_Node_Str")) {
        useLocalStorage=true;
      }
    }
 else {
      useLocalStorage=diskOffering.getUseLocalStorage();
    }
    diskProfile.setUseLocalStorage(useLocalStorage);
    boolean foundPotentialPools=false;
    Enumeration<StoragePoolAllocator> enPool=_storagePoolAllocators.enumeration();
    while (enPool.hasMoreElements()) {
      final StoragePoolAllocator allocator=enPool.nextElement();
      final List<StoragePool> suitablePools=allocator.allocateToPool(diskProfile,vmProfile.getTemplate(),plan,avoid,returnUpTo);
      if (suitablePools != null && !suitablePools.isEmpty()) {
        suitableVolumeStoragePools.put(toBeCreated,suitablePools);
        foundPotentialPools=true;
        break;
      }
    }
    if (!foundPotentialPools) {
      s_logger.debug("String_Node_Str" + toBeCreated + "String_Node_Str"+ plan.getClusterId());
      suitableVolumeStoragePools.clear();
      break;
    }
  }
  if (suitableVolumeStoragePools.isEmpty()) {
    s_logger.debug("String_Node_Str");
  }
  return new Pair<Map<Volume,List<StoragePool>>,List<Volume>>(suitableVolumeStoragePools,readyAndReusedVolumes);
}