Program: 120447
Project: 120447
Buggy source:
/** 
 * export the sected TOS model elements to the destination
 * @param destination zip file or folder to store the exported elements
 * @param items, the items to be exported
 * @param exportAllVersions whether all the versions are export or only the selected once
 * @param progressMonitor, to show the progress during export
 * @throws Exception in case of problem
 */
public void exportItems(File destination,Collection<Item> items,boolean exportAllVersions,IProgressMonitor progressMonitor) throws Exception {
  if (items == null) {
    items=new ArrayList<Item>();
  }
  Collection<Item> otherVersions=new ArrayList<Item>();
  if (exportAllVersions) {
    otherVersions=getOtherVersions(items);
    items.addAll(otherVersions);
    otherVersions.clear();
  }
  try {
    File tmpDirectory=null;
    Map<File,IPath> toExport;
    if (destination.getName().endsWith(FileConstants.TAR_FILE_SUFFIX)) {
      createFolder(destination.getParentFile());
      exporter=new TarFileExporterFullPath(destination.getAbsolutePath(),false);
    }
 else     if (destination.getName().endsWith(FileConstants.TAR_GZ_FILE_SUFFIX)) {
      createFolder(destination.getParentFile());
      exporter=new TarFileExporterFullPath(destination.getAbsolutePath(),true);
    }
 else     if (destination.getName().endsWith(FileConstants.ZIP_FILE_SUFFIX)) {
      createFolder(destination.getParentFile());
      exporter=new ZipFileExporterFullPath(destination.getAbsolutePath(),true);
    }
 else {
      createFolder(destination);
    }
    if (exporter != null) {
      tmpDirectory=createTmpDirectory();
    }
    try {
      if (exporter != null) {
        toExport=exportItems2(items,tmpDirectory,true,progressMonitor);
        for (        File file : toExport.keySet()) {
          IPath path=toExport.get(file);
          exporter.write(file.getAbsolutePath(),path.toString());
        }
      }
 else {
        toExport=exportItems2(items,destination,true,progressMonitor);
      }
    }
 catch (    Exception e) {
      throw e;
    }
 finally {
      if (exporter != null) {
        deleteTmpDirectory(tmpDirectory);
      }
    }
  }
  finally {
    if (exporter != null) {
      try {
        exporter.finished();
      }
 catch (      Exception e) {
        ExceptionHandler.process(e);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * export the sected TOS model elements to the destination
 * @param destination zip file or folder to store the exported elements
 * @param items, the items to be exported
 * @param exportAllVersions whether all the versions are export or only the selected once
 * @param progressMonitor, to show the progress during export
 * @throws Exception in case of problem
 */
public void exportItems(File destination,Collection<Item> items,boolean exportAllVersions,IProgressMonitor progressMonitor) throws Exception {
  if (items == null) {
    items=new ArrayList<Item>();
  }
  Collection<Item> otherVersions=new ArrayList<Item>();
  if (exportAllVersions) {
    otherVersions=getOtherVersions(items);
    items.addAll(otherVersions);
    otherVersions.clear();
  }
  try {
    File tmpDirectory=null;
    Map<File,IPath> toExport;
    File parentDesFile=checkAndGetDesParentFile(destination);
    if (destination.getName().endsWith(FileConstants.TAR_FILE_SUFFIX)) {
      createFolder(parentDesFile);
      exporter=new TarFileExporterFullPath(destination.getAbsolutePath(),false);
    }
 else     if (destination.getName().endsWith(FileConstants.TAR_GZ_FILE_SUFFIX)) {
      createFolder(parentDesFile);
      exporter=new TarFileExporterFullPath(destination.getAbsolutePath(),true);
    }
 else     if (destination.getName().endsWith(FileConstants.ZIP_FILE_SUFFIX)) {
      createFolder(parentDesFile);
      exporter=new ZipFileExporterFullPath(destination.getAbsolutePath(),true);
    }
 else {
      createFolder(destination);
    }
    if (exporter != null) {
      tmpDirectory=createTmpDirectory();
    }
    try {
      if (exporter != null) {
        toExport=exportItems2(items,tmpDirectory,true,progressMonitor);
        for (        File file : toExport.keySet()) {
          IPath path=toExport.get(file);
          exporter.write(file.getAbsolutePath(),path.toString());
        }
      }
 else {
        toExport=exportItems2(items,destination,true,progressMonitor);
      }
    }
 catch (    Exception e) {
      throw e;
    }
 finally {
      if (exporter != null) {
        deleteTmpDirectory(tmpDirectory);
      }
    }
  }
  finally {
    if (exporter != null) {
      try {
        exporter.finished();
      }
 catch (      Exception e) {
        ExceptionHandler.process(e);
      }
    }
  }
}