Program: 106152
Project: 106152
Buggy source:
@Override public Answer copyVolumeFromPrimaryToSecondary(CopyCommand cmd){
  DataTO srcData=cmd.getSrcTO();
  DataTO destData=cmd.getDestTO();
  VolumeObjectTO srcVol=(VolumeObjectTO)srcData;
  VolumeObjectTO destVol=(VolumeObjectTO)destData;
  ImageFormat srcFormat=srcVol.getFormat();
  ImageFormat destFormat=destVol.getFormat();
  DataStoreTO srcStore=srcData.getDataStore();
  DataStoreTO destStore=destData.getDataStore();
  PrimaryDataStoreTO primaryStore=(PrimaryDataStoreTO)srcStore;
  if (!(destStore instanceof NfsTO)) {
    return new CopyCmdAnswer("String_Node_Str");
  }
  NfsTO nfsStore=(NfsTO)destStore;
  String srcVolumePath=srcData.getPath();
  String destVolumePath=destData.getPath();
  String secondaryStorageUrl=nfsStore.getUrl();
  KVMStoragePool secondaryStoragePool=null;
  try {
    String volumeName=UUID.randomUUID().toString();
    String destVolumeName=volumeName + "String_Node_Str" + destFormat.getFileExtension();
    KVMPhysicalDisk volume=storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(),primaryStore.getUuid(),srcVolumePath);
    volume.setFormat(PhysicalDiskFormat.valueOf(srcFormat.toString()));
    secondaryStoragePool=storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl);
    secondaryStoragePool.createFolder(destVolumePath);
    storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(),secondaryStoragePool.getUuid());
    secondaryStoragePool=storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl + File.separator + destVolumePath);
    storagePoolMgr.copyPhysicalDisk(volume,destVolumeName,secondaryStoragePool);
    VolumeObjectTO newVol=new VolumeObjectTO();
    newVol.setPath(destVolumePath + File.separator + destVolumeName);
    newVol.setFormat(destFormat);
    return new CopyCmdAnswer(newVol);
  }
 catch (  CloudRuntimeException e) {
    return new CopyCmdAnswer(e.toString());
  }
 finally {
    if (secondaryStoragePool != null) {
      storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(),secondaryStoragePool.getUuid());
    }
  }
}

Fixed version (ground truth):
@Override public Answer copyVolumeFromPrimaryToSecondary(CopyCommand cmd){
  DataTO srcData=cmd.getSrcTO();
  DataTO destData=cmd.getDestTO();
  VolumeObjectTO srcVol=(VolumeObjectTO)srcData;
  VolumeObjectTO destVol=(VolumeObjectTO)destData;
  ImageFormat srcFormat=srcVol.getFormat();
  ImageFormat destFormat=destVol.getFormat();
  DataStoreTO srcStore=srcData.getDataStore();
  DataStoreTO destStore=destData.getDataStore();
  PrimaryDataStoreTO primaryStore=(PrimaryDataStoreTO)srcStore;
  if (!(destStore instanceof NfsTO)) {
    return new CopyCmdAnswer("String_Node_Str");
  }
  NfsTO nfsStore=(NfsTO)destStore;
  String srcVolumePath=srcData.getPath();
  String destVolumePath=destData.getPath();
  String secondaryStorageUrl=nfsStore.getUrl();
  KVMStoragePool secondaryStoragePool=null;
  try {
    String volumeName=UUID.randomUUID().toString();
    String destVolumeName=volumeName + "String_Node_Str" + destFormat.getFileExtension();
    KVMPhysicalDisk volume=storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(),primaryStore.getUuid(),srcVolumePath);
    volume.setFormat(PhysicalDiskFormat.valueOf(srcFormat.toString()));
    secondaryStoragePool=storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl);
    secondaryStoragePool.createFolder(destVolumePath);
    storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(),secondaryStoragePool.getUuid());
    secondaryStoragePool=storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl + File.separator + destVolumePath);
    storagePoolMgr.copyPhysicalDisk(volume,destVolumeName,secondaryStoragePool,cmd.getWaitInMillSeconds());
    VolumeObjectTO newVol=new VolumeObjectTO();
    newVol.setPath(destVolumePath + File.separator + destVolumeName);
    newVol.setFormat(destFormat);
    return new CopyCmdAnswer(newVol);
  }
 catch (  CloudRuntimeException e) {
    return new CopyCmdAnswer(e.toString());
  }
 finally {
    if (secondaryStoragePool != null) {
      storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(),secondaryStoragePool.getUuid());
    }
  }
}