Program: 105500
Project: 105500
Buggy source:
private List<VolumeTask> getTasks(List<VolumeVO> vols,Map<Volume,StoragePool> destVols,VirtualMachineProfile vm) throws StorageUnavailableException {
  boolean recreate=RecreatableSystemVmEnabled.value();
  List<VolumeTask> tasks=new ArrayList<VolumeTask>();
  for (  VolumeVO vol : vols) {
    StoragePoolVO assignedPool=null;
    if (destVols != null) {
      StoragePool pool=destVols.get(vol);
      if (pool != null) {
        assignedPool=_storagePoolDao.findById(pool.getId());
      }
    }
    if (assignedPool == null && recreate) {
      assignedPool=_storagePoolDao.findById(vol.getPoolId());
    }
    if (assignedPool != null || recreate) {
      Volume.State state=vol.getState();
      if (state == Volume.State.Allocated || state == Volume.State.Creating) {
        VolumeTask task=new VolumeTask(VolumeTaskType.RECREATE,vol,null);
        tasks.add(task);
      }
 else {
        if (vol.isRecreatable()) {
          if (s_logger.isDebugEnabled()) {
            s_logger.debug("String_Node_Str" + vol + "String_Node_Str"+ assignedPool+ "String_Node_Str");
          }
          VolumeTask task=new VolumeTask(VolumeTaskType.RECREATE,vol,null);
          tasks.add(task);
        }
 else {
          if (assignedPool.getId() != vol.getPoolId()) {
            if (s_logger.isDebugEnabled()) {
              s_logger.debug("String_Node_Str" + assignedPool + "String_Node_Str"+ vol);
            }
            DiskOffering diskOffering=_entityMgr.findById(DiskOffering.class,vol.getDiskOfferingId());
            if (diskOffering.getUseLocalStorage()) {
              if (s_logger.isDebugEnabled()) {
                s_logger.debug("String_Node_Str" + vol + "String_Node_Str"+ assignedPool+ "String_Node_Str");
              }
              throw new CloudRuntimeException("String_Node_Str" + vol + "String_Node_Str"+ assignedPool+ "String_Node_Str");
            }
 else {
              Boolean isHAOperation=(Boolean)vm.getParameter(VirtualMachineProfile.Param.HaOperation);
              Boolean storageMigrationEnabled=true;
              if (isHAOperation != null && isHAOperation) {
                storageMigrationEnabled=StorageHAMigrationEnabled.value();
              }
 else {
                storageMigrationEnabled=StorageMigrationEnabled.value();
              }
              if (storageMigrationEnabled) {
                if (s_logger.isDebugEnabled()) {
                  s_logger.debug("String_Node_Str" + vol + "String_Node_Str"+ assignedPool+ "String_Node_Str");
                }
                VolumeTask task=new VolumeTask(VolumeTaskType.MIGRATE,vol,assignedPool);
                tasks.add(task);
              }
 else {
                throw new CloudRuntimeException("String_Node_Str");
              }
            }
          }
 else {
            StoragePoolVO pool=_storagePoolDao.findById(vol.getPoolId());
            VolumeTask task=new VolumeTask(VolumeTaskType.NOP,vol,pool);
            tasks.add(task);
          }
        }
      }
    }
 else {
      if (vol.getPoolId() == null) {
        throw new StorageUnavailableException("String_Node_Str" + vol,Volume.class,vol.getId());
      }
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + vol + "String_Node_Str"+ vol.getPoolId()+ "String_Node_Str");
      }
      StoragePoolVO pool=_storagePoolDao.findById(vol.getPoolId());
      VolumeTask task=new VolumeTask(VolumeTaskType.NOP,vol,pool);
      tasks.add(task);
    }
  }
  return tasks;
}

Fixed version (ground truth):
private List<VolumeTask> getTasks(List<VolumeVO> vols,Map<Volume,StoragePool> destVols,VirtualMachineProfile vm) throws StorageUnavailableException {
  boolean recreate=RecreatableSystemVmEnabled.value();
  List<VolumeTask> tasks=new ArrayList<VolumeTask>();
  for (  VolumeVO vol : vols) {
    StoragePoolVO assignedPool=null;
    if (destVols != null) {
      StoragePool pool=destVols.get(vol);
      if (pool != null) {
        assignedPool=_storagePoolDao.findById(pool.getId());
      }
    }
    if (assignedPool == null && recreate) {
      assignedPool=_storagePoolDao.findById(vol.getPoolId());
    }
    if (assignedPool != null) {
      Volume.State state=vol.getState();
      if (state == Volume.State.Allocated || state == Volume.State.Creating) {
        VolumeTask task=new VolumeTask(VolumeTaskType.RECREATE,vol,null);
        tasks.add(task);
      }
 else {
        if (vol.isRecreatable()) {
          if (s_logger.isDebugEnabled()) {
            s_logger.debug("String_Node_Str" + vol + "String_Node_Str"+ assignedPool+ "String_Node_Str");
          }
          VolumeTask task=new VolumeTask(VolumeTaskType.RECREATE,vol,null);
          tasks.add(task);
        }
 else {
          if (assignedPool.getId() != vol.getPoolId()) {
            if (s_logger.isDebugEnabled()) {
              s_logger.debug("String_Node_Str" + assignedPool + "String_Node_Str"+ vol);
            }
            DiskOffering diskOffering=_entityMgr.findById(DiskOffering.class,vol.getDiskOfferingId());
            if (diskOffering.getUseLocalStorage()) {
              if (s_logger.isDebugEnabled()) {
                s_logger.debug("String_Node_Str" + vol + "String_Node_Str"+ assignedPool+ "String_Node_Str");
              }
              throw new CloudRuntimeException("String_Node_Str" + vol + "String_Node_Str"+ assignedPool+ "String_Node_Str");
            }
 else {
              Boolean isHAOperation=(Boolean)vm.getParameter(VirtualMachineProfile.Param.HaOperation);
              Boolean storageMigrationEnabled=true;
              if (isHAOperation != null && isHAOperation) {
                storageMigrationEnabled=StorageHAMigrationEnabled.value();
              }
 else {
                storageMigrationEnabled=StorageMigrationEnabled.value();
              }
              if (storageMigrationEnabled) {
                if (s_logger.isDebugEnabled()) {
                  s_logger.debug("String_Node_Str" + vol + "String_Node_Str"+ assignedPool+ "String_Node_Str");
                }
                VolumeTask task=new VolumeTask(VolumeTaskType.MIGRATE,vol,assignedPool);
                tasks.add(task);
              }
 else {
                throw new CloudRuntimeException("String_Node_Str");
              }
            }
          }
 else {
            StoragePoolVO pool=_storagePoolDao.findById(vol.getPoolId());
            VolumeTask task=new VolumeTask(VolumeTaskType.NOP,vol,pool);
            tasks.add(task);
          }
        }
      }
    }
 else {
      if (vol.getPoolId() == null) {
        throw new StorageUnavailableException("String_Node_Str" + vol,Volume.class,vol.getId());
      }
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + vol + "String_Node_Str"+ vol.getPoolId()+ "String_Node_Str");
      }
      StoragePoolVO pool=_storagePoolDao.findById(vol.getPoolId());
      VolumeTask task=new VolumeTask(VolumeTaskType.NOP,vol,pool);
      tasks.add(task);
    }
  }
  return tasks;
}