Program: 125339
Project: 125339
Buggy source:
private void importItemRecordsWithRelations(final IProgressMonitor monitor,final ResourcesManager manager,final List<ImportItem> processingItemRecords,final boolean overwriting,ImportItem[] allPopulatedImportItemRecords,IPath destinationPath,final Set<String> overwriteDeletedItems,final Set<String> idDeletedBeforeImport) throws Exception {
  boolean hasJoblet=false;
  boolean reloadJoblet=false;
  for (  ImportItem itemRecord : processingItemRecords) {
    if (monitor.isCanceled()) {
      return;
    }
    if (itemRecord.isImported()) {
      continue;
    }
    if ((ERepositoryObjectType.JOBLET == itemRecord.getRepositoryType()) || (ERepositoryObjectType.SPARK_JOBLET == itemRecord.getRepositoryType()) || (ERepositoryObjectType.SPARK_STREAMING_JOBLET == itemRecord.getRepositoryType())) {
      hasJoblet=true;
    }
    if (hasJoblet) {
      if (ERepositoryObjectType.JOBLET != itemRecord.getRepositoryType() && ERepositoryObjectType.SPARK_JOBLET != itemRecord.getRepositoryType() && ERepositoryObjectType.SPARK_STREAMING_JOBLET != itemRecord.getRepositoryType()) {
        reloadJoblet=true;
        if (PluginChecker.isJobLetPluginLoaded()) {
          IJobletProviderService jobletService=(IJobletProviderService)GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
          if (jobletService != null) {
            jobletService.loadComponentsFromProviders();
          }
        }
      }
    }
    try {
      final IImportItemsHandler importHandler=itemRecord.getImportHandler();
      if (importHandler != null && itemRecord.isValid()) {
        List<ImportItem> relatedItemRecord=importHandler.findRelatedImportItems(monitor,manager,itemRecord,allPopulatedImportItemRecords);
        if (importHandler.isPriorImportRelatedItem()) {
          if (!relatedItemRecord.isEmpty()) {
            importItemRecordsWithRelations(monitor,manager,relatedItemRecord,overwriting,allPopulatedImportItemRecords,destinationPath,overwriteDeletedItems,idDeletedBeforeImport);
          }
        }
        if (monitor.isCanceled()) {
          return;
        }
        importHandler.doImport(monitor,manager,itemRecord,overwriting,destinationPath,overwriteDeletedItems,idDeletedBeforeImport);
        if (monitor.isCanceled()) {
          return;
        }
        if (!importHandler.isPriorImportRelatedItem()) {
          if (!relatedItemRecord.isEmpty()) {
            importItemRecordsWithRelations(monitor,manager,relatedItemRecord,overwriting,allPopulatedImportItemRecords,destinationPath,overwriteDeletedItems,idDeletedBeforeImport);
          }
        }
        importHandler.afterImportingItems(monitor,manager,itemRecord);
        ImportCacheHelper.getInstance().getImportedItemRecords().add(itemRecord);
        monitor.worked(1);
      }
    }
 catch (    Exception e) {
      if (Platform.inDebugMode()) {
        itemRecord.addError(e.getMessage());
        ImportCacheHelper.getInstance().setImportingError(true);
        ExceptionHandler.process(e);
      }
    }
  }
  if (hasJoblet && !reloadJoblet && PluginChecker.isJobLetPluginLoaded()) {
    IJobletProviderService jobletService=(IJobletProviderService)GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
    if (jobletService != null) {
      jobletService.loadComponentsFromProviders();
    }
  }
}

Fixed version (ground truth):
private void importItemRecordsWithRelations(final IProgressMonitor monitor,final ResourcesManager manager,final List<ImportItem> processingItemRecords,final boolean overwriting,ImportItem[] allPopulatedImportItemRecords,IPath destinationPath,final Set<String> overwriteDeletedItems,final Set<String> idDeletedBeforeImport) throws Exception {
  boolean hasJoblet=false;
  boolean jobletReloaded=false;
  for (  ImportItem itemRecord : processingItemRecords) {
    if (monitor.isCanceled()) {
      return;
    }
    if (itemRecord.isImported()) {
      continue;
    }
    if ((ERepositoryObjectType.JOBLET == itemRecord.getRepositoryType()) || (ERepositoryObjectType.SPARK_JOBLET == itemRecord.getRepositoryType()) || (ERepositoryObjectType.SPARK_STREAMING_JOBLET == itemRecord.getRepositoryType())) {
      hasJoblet=true;
    }
    if (hasJoblet && !jobletReloaded) {
      if (ERepositoryObjectType.JOBLET != itemRecord.getRepositoryType() && ERepositoryObjectType.SPARK_JOBLET != itemRecord.getRepositoryType() && ERepositoryObjectType.SPARK_STREAMING_JOBLET != itemRecord.getRepositoryType()) {
        jobletReloaded=true;
        if (PluginChecker.isJobLetPluginLoaded()) {
          IJobletProviderService jobletService=(IJobletProviderService)GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
          if (jobletService != null) {
            jobletService.loadComponentsFromProviders();
          }
        }
      }
    }
    try {
      final IImportItemsHandler importHandler=itemRecord.getImportHandler();
      if (importHandler != null && itemRecord.isValid()) {
        List<ImportItem> relatedItemRecord=importHandler.findRelatedImportItems(monitor,manager,itemRecord,allPopulatedImportItemRecords);
        if (importHandler.isPriorImportRelatedItem()) {
          if (!relatedItemRecord.isEmpty()) {
            importItemRecordsWithRelations(monitor,manager,relatedItemRecord,overwriting,allPopulatedImportItemRecords,destinationPath,overwriteDeletedItems,idDeletedBeforeImport);
          }
        }
        if (monitor.isCanceled()) {
          return;
        }
        importHandler.doImport(monitor,manager,itemRecord,overwriting,destinationPath,overwriteDeletedItems,idDeletedBeforeImport);
        if (monitor.isCanceled()) {
          return;
        }
        if (!importHandler.isPriorImportRelatedItem()) {
          if (!relatedItemRecord.isEmpty()) {
            importItemRecordsWithRelations(monitor,manager,relatedItemRecord,overwriting,allPopulatedImportItemRecords,destinationPath,overwriteDeletedItems,idDeletedBeforeImport);
          }
        }
        importHandler.afterImportingItems(monitor,manager,itemRecord);
        ImportCacheHelper.getInstance().getImportedItemRecords().add(itemRecord);
        monitor.worked(1);
      }
    }
 catch (    Exception e) {
      if (Platform.inDebugMode()) {
        itemRecord.addError(e.getMessage());
        ImportCacheHelper.getInstance().setImportingError(true);
        ExceptionHandler.process(e);
      }
    }
  }
  if (hasJoblet && !jobletReloaded && PluginChecker.isJobLetPluginLoaded()) {
    IJobletProviderService jobletService=(IJobletProviderService)GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
    if (jobletService != null) {
      jobletService.loadComponentsFromProviders();
    }
  }
}