Program: 106317
Project: 106317
Buggy source:
private void restoreVolumeFromSecStorage(VmwareHypervisorHost hyperHost,DatastoreMO primaryDsMo,String newVolumeName,String secStorageUrl,String secStorageDir,String backupName) throws Exception {
  String secondaryMountPoint=_mountService.getMountPoint(secStorageUrl);
  String srcOVAFileName=secondaryMountPoint + "String_Node_Str" + secStorageDir+ "String_Node_Str"+ backupName+ "String_Node_Str"+ ImageFormat.OVA.getFileExtension();
  String srcFileName=getOVFFilePath(srcOVAFileName);
  if (srcFileName == null) {
    Script command=new Script("String_Node_Str",0,s_logger);
    command.add("String_Node_Str");
    command.add("String_Node_Str",srcOVAFileName);
    command.setWorkDir(secondaryMountPoint + "String_Node_Str" + secStorageDir);
    s_logger.info("String_Node_Str" + command.toString());
    String result=command.execute();
    if (result != null) {
      String msg="String_Node_Str" + srcOVAFileName;
      s_logger.error(msg);
      throw new Exception(msg);
    }
  }
  srcFileName=getOVFFilePath(srcOVAFileName);
  if (srcFileName == null) {
    String msg="String_Node_Str" + srcOVAFileName;
    s_logger.error(msg);
    throw new Exception(msg);
  }
  VirtualMachineMO clonedVm=null;
  try {
    hyperHost.importVmFromOVF(srcFileName,newVolumeName,primaryDsMo,"String_Node_Str");
    clonedVm=hyperHost.findVmOnHyperHost(newVolumeName);
    if (clonedVm == null)     throw new Exception("String_Node_Str");
    clonedVm.moveAllVmDiskFiles(primaryDsMo,"String_Node_Str",false);
    clonedVm.detachAllDisks();
  }
  finally {
    if (clonedVm != null) {
      clonedVm.detachAllDisks();
      clonedVm.destroy();
    }
  }
}

Fixed version (ground truth):
private void restoreVolumeFromSecStorage(VmwareHypervisorHost hyperHost,DatastoreMO primaryDsMo,String newVolumeName,String secStorageUrl,String secStorageDir,String backupName) throws Exception {
  String secondaryMountPoint=_mountService.getMountPoint(secStorageUrl);
  String srcOVAFileName=secondaryMountPoint + "String_Node_Str" + secStorageDir+ "String_Node_Str"+ backupName+ "String_Node_Str"+ ImageFormat.OVA.getFileExtension();
  String snapshotDir="String_Node_Str";
  if (backupName.contains("String_Node_Str")) {
    snapshotDir=backupName.split("String_Node_Str")[0];
  }
  String srcFileName=getOVFFilePath(srcOVAFileName);
  if (srcFileName == null) {
    Script command=new Script("String_Node_Str",0,s_logger);
    command.add("String_Node_Str");
    command.add("String_Node_Str",srcOVAFileName);
    command.setWorkDir(secondaryMountPoint + "String_Node_Str" + secStorageDir+ "String_Node_Str"+ snapshotDir);
    s_logger.info("String_Node_Str" + command.toString());
    String result=command.execute();
    if (result != null) {
      String msg="String_Node_Str" + srcOVAFileName;
      s_logger.error(msg);
      throw new Exception(msg);
    }
  }
  srcFileName=getOVFFilePath(srcOVAFileName);
  if (srcFileName == null) {
    String msg="String_Node_Str" + srcOVAFileName;
    s_logger.error(msg);
    throw new Exception(msg);
  }
  VirtualMachineMO clonedVm=null;
  try {
    hyperHost.importVmFromOVF(srcFileName,newVolumeName,primaryDsMo,"String_Node_Str");
    clonedVm=hyperHost.findVmOnHyperHost(newVolumeName);
    if (clonedVm == null)     throw new Exception("String_Node_Str");
    clonedVm.moveAllVmDiskFiles(primaryDsMo,"String_Node_Str",false);
    clonedVm.detachAllDisks();
  }
  finally {
    if (clonedVm != null) {
      clonedVm.detachAllDisks();
      clonedVm.destroy();
    }
  }
}