Program: 127130
Project: 127130
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);
  final Item item=selectedItemRecord.getItem();
  if (item != null) {
    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)) {
          if (idDeletedBeforeImport != null && !idDeletedBeforeImport.contains(id)) {
            List<IRepositoryViewObject> allVersionToDelete=repFactory.getAllVersion(ProjectManager.getInstance().getCurrentProject(),lastVersion.getId(),false);
            for (            IRepositoryViewObject currentVersion : allVersionToDelete) {
              repFactory.forceDeleteObjectPhysical(lastVersion,currentVersion.getVersion());
            }
            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);
    }
  }
  String label=selectedItemRecord.getLabel();
  for (  Resource resource : selectedItemRecord.getResourceSet().getResources()) {
    if (!(resource instanceof ByteArrayResource)) {
      resource.unload();
    }
  }
  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);
  final Item item=selectedItemRecord.getItem();
  if (item != null) {
    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)) {
          if (idDeletedBeforeImport != null && !idDeletedBeforeImport.contains(id)) {
            List<IRepositoryViewObject> allVersionToDelete=repFactory.getAllVersion(ProjectManager.getInstance().getCurrentProject(),lastVersion.getId(),false);
            for (            IRepositoryViewObject currentVersion : allVersionToDelete) {
              repFactory.forceDeleteObjectPhysical(lastVersion,currentVersion.getVersion());
            }
            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);
}