Program: 123431
Project: 123431
Buggy source:
private Map<File,IPath> exportItems(Collection<Item> items,File destinationDirectory,boolean projectFolderStructure,IProgressMonitor progressMonitor) throws Exception {
  Map<File,IPath> toExport=new HashMap<File,IPath>();
  progressMonitor.beginTask("String_Node_Str",items.size() + 1);
  ResourceSetImpl resourceSet=new ResourceSetImpl();
  TimeMeasure.display=CommonsPlugin.isDebugMode();
  TimeMeasure.displaySteps=CommonsPlugin.isDebugMode();
  TimeMeasure.measureActive=CommonsPlugin.isDebugMode();
  TimeMeasure.begin("String_Node_Str");
  try {
    Map<Item,Project> itemProjectMap=new HashMap<Item,Project>();
    Collection<Item> allItems=new ArrayList<Item>(items);
    items.clear();
    allItems=sortItemsByProject(allItems,itemProjectMap);
    itemProjectMap.clear();
    Set<String> jarNameList=new HashSet<String>();
    Iterator<Item> iterator=allItems.iterator();
    while (iterator.hasNext()) {
      Item item=iterator.next();
      project=pManager.getProject(item);
      String label=item.getProperty().getLabel();
      computeProjectFileAndPath(destinationDirectory);
      if (!toExport.containsKey(projectFile)) {
        createProjectResource(resourceSet,allItems);
        toExport.put(projectFile,projectPath);
      }
      if (ERepositoryObjectType.getItemType(item).isResourceItem()) {
        Collection<EObject> copiedObjects=copyObjects(item);
        Item copiedItem=(Item)EcoreUtil.getObjectByType(copiedObjects,PropertiesPackage.eINSTANCE.getItem());
        fixItem(copiedItem);
        computeItemFilesAndPaths(destinationDirectory,copiedItem,projectFolderStructure);
        createItemResources(copiedItem,copiedObjects,resourceSet);
        createReferenceFileItemReources(resourceSet);
        fixItemUserReferences(copiedItem);
        fixItemLockState();
        toExport.put(propertyFile,propertyPath);
        toExport.put(itemFile,itemPath);
        int id=item.eClass().getClassifierID();
        if (id == PropertiesPackage.PROCESS_ITEM || id == PropertiesPackage.JOBLET_PROCESS_ITEM) {
          toExport.put(screenshotFile,screenshotPath);
        }
        if (refereneceFilesToBeExport != null && !refereneceFilesToBeExport.isEmpty()) {
          for (          File rfFile : refereneceFilesToBeExport.keySet()) {
            IPath rFPath=refereneceFilesToBeExport.get(rfFile);
            toExport.put(rfFile,rFPath);
          }
        }
      }
      if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.JAVA)) {
        if (item instanceof RoutineItem) {
          List list=((RoutineItem)item).getImports();
          for (int i=0; i < list.size(); i++) {
            String jarName=((IMPORTTypeImpl)list.get(i)).getMODULE();
            jarNameList.add(jarName.toString());
          }
        }
      }
      progressMonitor.worked(1);
      dereferenceNotContainedObjects(resourceSet);
      saveResources(resourceSet);
      if (!ERepositoryStatus.LOCK_BY_USER.equals(ProxyRepositoryFactory.getInstance().getStatus(item))) {
        ProxyRepositoryFactory.getInstance().unloadResources(item.getProperty());
        if (item.getParent() != null && item.getParent() instanceof FolderItem) {
          ((FolderItem)item.getParent()).getChildren().remove(item);
          item.setParent(null);
        }
      }
 else {
        List<ReferenceFileItem> referenceFiles=(List<ReferenceFileItem>)item.getReferenceResources();
        if (referenceFiles != null && !referenceFiles.isEmpty()) {
          ProxyRepositoryFactory.getInstance().unloadResources(item.getProperty());
        }
      }
      iterator.remove();
      cleanResources(resourceSet);
      TimeMeasure.step("String_Node_Str","String_Node_Str" + label);
    }
    ILibraryManagerService repositoryBundleService=CorePlugin.getDefault().getRepositoryBundleService();
    for (    String jarName : jarNameList) {
      IPath jarPath=new Path(getNeedProjectPath()).append("String_Node_Str");
      String filePath=new Path(destinationDirectory.toString()).append(jarPath.toString()).toPortableString();
      if (repositoryBundleService.contains(jarName)) {
        repositoryBundleService.retrieve(jarName,filePath,new NullProgressMonitor());
        toExport.put(new File(new Path(filePath).append(jarName).toPortableString()),jarPath.append(jarName));
      }
    }
    progressMonitor.worked(1);
  }
 catch (  Exception e) {
    throw e;
  }
 finally {
    cleanResources(resourceSet);
    TimeMeasure.end("String_Node_Str");
    TimeMeasure.display=false;
    TimeMeasure.displaySteps=false;
    TimeMeasure.measureActive=false;
  }
  return toExport;
}

Fixed version (ground truth):
private Map<File,IPath> exportItems(Collection<Item> items,File destinationDirectory,boolean projectFolderStructure,IProgressMonitor progressMonitor) throws Exception {
  Map<File,IPath> toExport=new HashMap<File,IPath>();
  progressMonitor.beginTask("String_Node_Str",items.size() + 1);
  ResourceSetImpl resourceSet=new ResourceSetImpl();
  TimeMeasure.display=CommonsPlugin.isDebugMode();
  TimeMeasure.displaySteps=CommonsPlugin.isDebugMode();
  TimeMeasure.measureActive=CommonsPlugin.isDebugMode();
  TimeMeasure.begin("String_Node_Str");
  try {
    Map<Item,Project> itemProjectMap=new HashMap<Item,Project>();
    Collection<Item> allItems=new ArrayList<Item>(items);
    items.clear();
    allItems=sortItemsByProject(allItems,itemProjectMap);
    itemProjectMap.clear();
    Set<String> jarNameList=new HashSet<String>();
    computeProjectFileAndPath(destinationDirectory);
    if (!toExport.containsKey(projectFile)) {
      createProjectResource(resourceSet,allItems);
      saveResources(resourceSet);
      toExport.put(projectFile,projectPath);
    }
    Iterator<Item> iterator=allItems.iterator();
    while (iterator.hasNext()) {
      Item item=iterator.next();
      project=pManager.getProject(item);
      String label=item.getProperty().getLabel();
      if (ERepositoryObjectType.getItemType(item).isResourceItem()) {
        Collection<EObject> copiedObjects=copyObjects(item);
        Item copiedItem=(Item)EcoreUtil.getObjectByType(copiedObjects,PropertiesPackage.eINSTANCE.getItem());
        fixItem(copiedItem);
        computeItemFilesAndPaths(destinationDirectory,copiedItem,projectFolderStructure);
        createItemResources(copiedItem,copiedObjects,resourceSet);
        createReferenceFileItemReources(resourceSet);
        fixItemUserReferences(copiedItem);
        fixItemLockState();
        toExport.put(propertyFile,propertyPath);
        toExport.put(itemFile,itemPath);
        int id=item.eClass().getClassifierID();
        if (id == PropertiesPackage.PROCESS_ITEM || id == PropertiesPackage.JOBLET_PROCESS_ITEM) {
          toExport.put(screenshotFile,screenshotPath);
        }
        if (refereneceFilesToBeExport != null && !refereneceFilesToBeExport.isEmpty()) {
          for (          File rfFile : refereneceFilesToBeExport.keySet()) {
            IPath rFPath=refereneceFilesToBeExport.get(rfFile);
            toExport.put(rfFile,rFPath);
          }
        }
      }
      if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.JAVA)) {
        if (item instanceof RoutineItem) {
          List list=((RoutineItem)item).getImports();
          for (int i=0; i < list.size(); i++) {
            String jarName=((IMPORTTypeImpl)list.get(i)).getMODULE();
            jarNameList.add(jarName.toString());
          }
        }
      }
      progressMonitor.worked(1);
      dereferenceNotContainedObjects(resourceSet);
      saveResources(resourceSet);
      if (!ERepositoryStatus.LOCK_BY_USER.equals(ProxyRepositoryFactory.getInstance().getStatus(item))) {
        ProxyRepositoryFactory.getInstance().unloadResources(item.getProperty());
        if (item.getParent() != null && item.getParent() instanceof FolderItem) {
          ((FolderItem)item.getParent()).getChildren().remove(item);
          item.setParent(null);
        }
      }
 else {
        List<ReferenceFileItem> referenceFiles=(List<ReferenceFileItem>)item.getReferenceResources();
        if (referenceFiles != null && !referenceFiles.isEmpty()) {
          ProxyRepositoryFactory.getInstance().unloadResources(item.getProperty());
        }
      }
      iterator.remove();
      cleanResources(resourceSet);
      TimeMeasure.step("String_Node_Str","String_Node_Str" + label);
    }
    ILibraryManagerService repositoryBundleService=CorePlugin.getDefault().getRepositoryBundleService();
    for (    String jarName : jarNameList) {
      IPath jarPath=new Path(getNeedProjectPath()).append("String_Node_Str");
      String filePath=new Path(destinationDirectory.toString()).append(jarPath.toString()).toPortableString();
      if (repositoryBundleService.contains(jarName)) {
        repositoryBundleService.retrieve(jarName,filePath,new NullProgressMonitor());
        toExport.put(new File(new Path(filePath).append(jarName).toPortableString()),jarPath.append(jarName));
      }
    }
    progressMonitor.worked(1);
  }
 catch (  Exception e) {
    throw e;
  }
 finally {
    cleanResources(resourceSet);
    TimeMeasure.end("String_Node_Str");
    TimeMeasure.display=false;
    TimeMeasure.displaySteps=false;
    TimeMeasure.measureActive=false;
  }
  return toExport;
}