Program: 105140
Project: 105140
Buggy source:
@DB public VolumeInfo createVolume(VolumeInfo volume,VirtualMachine vm,VirtualMachineTemplate template,DataCenter dc,Pod pod,Long clusterId,ServiceOffering offering,DiskOffering diskOffering,List<StoragePool> avoids,long size,HypervisorType hyperType){
  volume=volService.updateHypervisorSnapshotReserveForVolume(diskOffering,volume.getId(),hyperType);
  StoragePool pool=null;
  DiskProfile dskCh=null;
  if (volume.getVolumeType() == Type.ROOT && Storage.ImageFormat.ISO != template.getFormat()) {
    dskCh=createDiskCharacteristics(volume,template,dc,offering);
  }
 else {
    dskCh=createDiskCharacteristics(volume,template,dc,diskOffering);
  }
  if (diskOffering != null && diskOffering.isCustomized()) {
    dskCh.setSize(size);
  }
  dskCh.setHyperType(hyperType);
  final HashSet<StoragePool> avoidPools=new HashSet<StoragePool>(avoids);
  pool=findStoragePool(dskCh,dc,pod,clusterId,vm.getHostId(),vm,avoidPools);
  if (pool == null) {
    s_logger.warn("String_Node_Str" + volume.getName());
    throw new CloudRuntimeException("String_Node_Str" + volume.getName());
  }
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + volume + "String_Node_Str"+ pool);
  }
  DataStore store=dataStoreMgr.getDataStore(pool.getId(),DataStoreRole.Primary);
  for (int i=0; i < 2; i++) {
    AsyncCallFuture<VolumeApiResult> future=null;
    boolean isNotCreatedFromTemplate=volume.getTemplateId() == null ? true : false;
    if (isNotCreatedFromTemplate) {
      future=volService.createVolumeAsync(volume,store);
    }
 else {
      TemplateInfo templ=tmplFactory.getTemplate(template.getId(),DataStoreRole.Image);
      future=volService.createVolumeFromTemplateAsync(volume,store.getId(),templ);
    }
    try {
      VolumeApiResult result=future.get();
      if (result.isFailed()) {
        if (result.getResult().contains("String_Node_Str") && (i == 0)) {
          s_logger.debug("String_Node_Str");
          continue;
        }
 else {
          s_logger.debug("String_Node_Str" + result.getResult());
          throw new CloudRuntimeException("String_Node_Str" + result.getResult());
        }
      }
      return result.getVolume();
    }
 catch (    InterruptedException e) {
      s_logger.error("String_Node_Str",e);
      throw new CloudRuntimeException("String_Node_Str",e);
    }
catch (    ExecutionException e) {
      s_logger.error("String_Node_Str",e);
      throw new CloudRuntimeException("String_Node_Str",e);
    }
  }
  throw new CloudRuntimeException("String_Node_Str");
}

Fixed version (ground truth):
@DB public VolumeInfo createVolume(VolumeInfo volume,VirtualMachine vm,VirtualMachineTemplate template,DataCenter dc,Pod pod,Long clusterId,ServiceOffering offering,DiskOffering diskOffering,List<StoragePool> avoids,long size,HypervisorType hyperType){
  volume=volService.updateHypervisorSnapshotReserveForVolume(diskOffering,volume.getId(),hyperType);
  StoragePool pool=null;
  DiskProfile dskCh=null;
  if (volume.getVolumeType() == Type.ROOT && Storage.ImageFormat.ISO != template.getFormat()) {
    dskCh=createDiskCharacteristics(volume,template,dc,offering);
    storageMgr.setDiskProfileThrottling(dskCh,offering,diskOffering);
  }
 else {
    dskCh=createDiskCharacteristics(volume,template,dc,diskOffering);
    storageMgr.setDiskProfileThrottling(dskCh,null,diskOffering);
  }
  if (diskOffering != null && diskOffering.isCustomized()) {
    dskCh.setSize(size);
  }
  dskCh.setHyperType(hyperType);
  final HashSet<StoragePool> avoidPools=new HashSet<StoragePool>(avoids);
  pool=findStoragePool(dskCh,dc,pod,clusterId,vm.getHostId(),vm,avoidPools);
  if (pool == null) {
    s_logger.warn("String_Node_Str" + volume.getName());
    throw new CloudRuntimeException("String_Node_Str" + volume.getName());
  }
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + volume + "String_Node_Str"+ pool);
  }
  DataStore store=dataStoreMgr.getDataStore(pool.getId(),DataStoreRole.Primary);
  for (int i=0; i < 2; i++) {
    AsyncCallFuture<VolumeApiResult> future=null;
    boolean isNotCreatedFromTemplate=volume.getTemplateId() == null ? true : false;
    if (isNotCreatedFromTemplate) {
      future=volService.createVolumeAsync(volume,store);
    }
 else {
      TemplateInfo templ=tmplFactory.getTemplate(template.getId(),DataStoreRole.Image);
      future=volService.createVolumeFromTemplateAsync(volume,store.getId(),templ);
    }
    try {
      VolumeApiResult result=future.get();
      if (result.isFailed()) {
        if (result.getResult().contains("String_Node_Str") && (i == 0)) {
          s_logger.debug("String_Node_Str");
          continue;
        }
 else {
          s_logger.debug("String_Node_Str" + result.getResult());
          throw new CloudRuntimeException("String_Node_Str" + result.getResult());
        }
      }
      return result.getVolume();
    }
 catch (    InterruptedException e) {
      s_logger.error("String_Node_Str",e);
      throw new CloudRuntimeException("String_Node_Str",e);
    }
catch (    ExecutionException e) {
      s_logger.error("String_Node_Str",e);
      throw new CloudRuntimeException("String_Node_Str",e);
    }
  }
  throw new CloudRuntimeException("String_Node_Str");
}