Program: 126709
Project: 126709
Buggy source:
@Override public void importItemRecord(IProgressMonitor monitor,ResourcesManager resManager,ItemRecord selectedItemRecord,boolean overwrite,IPath destinationPath,Set<String> overwriteDeletedItems,Set<String> idDeletedBeforeImport){
  monitor.subTask(Messages.getString("String_Node_Str",selectedItemRecord.getItemName()));
  resolveItem(resManager,selectedItemRecord);
  if (!selectedItemRecord.isValid()) {
    return;
  }
  final Item item=selectedItemRecord.getItem();
  if (item != null) {
    final ProxyRepositoryFactory repFactory=ProxyRepositoryFactory.getInstance();
    ERepositoryObjectType itemType=ERepositoryObjectType.getItemType(item);
    IPath path=checkAndCreatePath(selectedItemRecord,destinationPath);
    try {
      Item tmpItem=item;
      String id=selectedItemRecord.getProperty().getId();
      IRepositoryViewObject lastVersion=selectedItemRecord.getExistingItemWithSameId();
      if (lastVersion != null && overwrite && !selectedItemRecord.isLocked() && (selectedItemRecord.getState() == State.ID_EXISTED || selectedItemRecord.getState() == State.NAME_EXISTED || selectedItemRecord.getState() == State.NAME_AND_ID_EXISTED) && !ImportCacheHelper.getInstance().getDeletedItems().contains(id)) {
        if (overwriteDeletedItems != null && !overwriteDeletedItems.contains(id)) {
          ERepositoryStatus status=repFactory.getStatus(lastVersion);
          if (status == ERepositoryStatus.DELETED) {
            repFactory.restoreObject(lastVersion,path);
          }
          overwriteDeletedItems.add(id);
        }
        if (selectedItemRecord.getState().equals(ItemRecord.State.NAME_EXISTED) || selectedItemRecord.getState().equals(ItemRecord.State.NAME_AND_ID_EXISTED)) {
          final IRepositoryViewObject lastVersionBackup=lastVersion;
          if (idDeletedBeforeImport != null && !idDeletedBeforeImport.contains(id)) {
            final List<IRepositoryViewObject> allVersionToDelete=repFactory.getAllVersion(ProjectManager.getInstance().getCurrentProject(),lastVersionBackup.getId(),false);
            RepositoryWorkUnit repositoryWorkUnit=new RepositoryWorkUnit(Messages.getString("String_Node_Str")){
              @Override public void run() throws PersistenceException {
                for (                IRepositoryViewObject currentVersion : allVersionToDelete) {
                  repFactory.forceDeleteObjectPhysical(lastVersionBackup,currentVersion.getVersion());
                }
              }
            }
;
            repositoryWorkUnit.setForceTransaction(true);
            repositoryWorkUnit.setRefreshRepository(false);
            ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(repositoryWorkUnit);
            idDeletedBeforeImport.add(id);
          }
        }
        lastVersion=null;
      }
      User author=selectedItemRecord.getProperty().getAuthor();
      if (author != null) {
        if (!repFactory.setAuthorByLogin(tmpItem,author.getLogin())) {
          tmpItem.getProperty().setAuthor(null);
        }
      }
      beforeCreatingItem(selectedItemRecord);
      final RepositoryObjectCache repObjectcache=ImportCacheHelper.getInstance().getRepObjectcache();
      if (lastVersion == null || selectedItemRecord.getState().equals(ItemRecord.State.ID_EXISTED)) {
        repFactory.create(tmpItem,path,true);
        afterCreatedItem(resManager,selectedItemRecord);
        selectedItemRecord.setImported(true);
      }
 else       if (VersionUtils.compareTo(lastVersion.getProperty().getVersion(),tmpItem.getProperty().getVersion()) < 0) {
        repFactory.forceCreate(tmpItem,path);
        afterForceCreatedItem(resManager,selectedItemRecord);
        selectedItemRecord.setImported(true);
      }
 else {
        PersistenceException e=new PersistenceException(Messages.getString("String_Node_Str",tmpItem.getProperty()));
        selectedItemRecord.addError(e.getMessage());
        logError(e);
      }
      if (selectedItemRecord.isImported()) {
        selectedItemRecord.setImportPath(path.toPortableString());
        selectedItemRecord.setRepositoryType(itemType);
        selectedItemRecord.setItemId(selectedItemRecord.getProperty().getId());
        selectedItemRecord.setItemVersion(selectedItemRecord.getProperty().getVersion());
        repObjectcache.addToCache(tmpItem);
      }
      if (tmpItem.getState() != null && itemType != null) {
        final Set<String> folders=ImportCacheHelper.getInstance().getRestoreFolder().getFolders(itemType);
        if (folders != null) {
          for (          String folderPath : folders) {
            if (folderPath != null && folderPath.equals(path.toString())) {
              FolderItem folderItem=repFactory.getFolderItem(ProjectManager.getInstance().getCurrentProject(),itemType,path);
              if (folderItem != null) {
                folderItem.getState().setDeleted(false);
                while (!(folderItem.getParent() instanceof Project)) {
                  folderItem=(FolderItem)folderItem.getParent();
                  if (folderItem.getType() == FolderType.SYSTEM_FOLDER_LITERAL) {
                    break;
                  }
                  folderItem.getState().setDeleted(false);
                }
              }
              break;
            }
          }
        }
      }
    }
 catch (    Exception e) {
      selectedItemRecord.addError(e.getMessage());
      logError(e);
    }
  }
  EList<Resource> resources=selectedItemRecord.getResourceSet().getResources();
  Iterator<Resource> iterator=resources.iterator();
  while (iterator.hasNext()) {
    Resource res=iterator.next();
    if (res != null && !(res instanceof ByteArrayResource)) {
      res.unload();
      iterator.remove();
    }
  }
  String label=selectedItemRecord.getLabel();
  TimeMeasure.step("String_Node_Str","String_Node_Str" + label);
  applyMigrationTasks(selectedItemRecord,monitor);
  TimeMeasure.step("String_Node_Str","String_Node_Str" + label);
}

Fixed version (ground truth):
@Override public void importItemRecord(IProgressMonitor monitor,ResourcesManager resManager,ItemRecord selectedItemRecord,boolean overwrite,IPath destinationPath,Set<String> overwriteDeletedItems,Set<String> idDeletedBeforeImport){
  monitor.subTask(Messages.getString("String_Node_Str",selectedItemRecord.getItemName()));
  resolveItem(resManager,selectedItemRecord);
  if (!selectedItemRecord.isValid()) {
    return;
  }
  doImportItem(monitor,resManager,selectedItemRecord,overwrite,destinationPath,overwriteDeletedItems,idDeletedBeforeImport);
  EList<Resource> resources=selectedItemRecord.getResourceSet().getResources();
  Iterator<Resource> iterator=resources.iterator();
  while (iterator.hasNext()) {
    Resource res=iterator.next();
    if (res != null && !(res instanceof ByteArrayResource)) {
      res.unload();
      iterator.remove();
    }
  }
  String label=selectedItemRecord.getLabel();
  TimeMeasure.step("String_Node_Str","String_Node_Str" + label);
  applyMigrationTasks(selectedItemRecord,monitor);
  TimeMeasure.step("String_Node_Str","String_Node_Str" + label);
}