mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
2 days ago 3800973a69c23deb5c770e8032074244f50f5b9a
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/OnDiskMergeImporter.java
@@ -1195,6 +1195,33 @@
  private void doImport(final Source source) throws InterruptedException, ExecutionException
  {
    try
    {
      importAllEntries(source);
    }
    catch (Throwable t)
    {
      // Cancellation lands here as well (see the InterruptedException below). The trees hold an
      // incomplete import: the storage must not treat what is in them as the final data. Errors
      // are caught too - an import killed by an OutOfMemoryError leaves the trees just as partial
      // as one killed by an exception.
      try
      {
        importStrategy.aborted();
      }
      catch (Throwable notified)
      {
        // What went wrong here matters less than what brought the import down: the report of the
        // failure is the point of this block. Concrete for the motivating case, an import killed
        // by an OutOfMemoryError, where notifying the storage allocates.
        t.addSuppressed(notified);
      }
      throw t;
    }
  }
  private void importAllEntries(final Source source) throws InterruptedException, ExecutionException
  {
    final long phaseOneStartTime = System.currentTimeMillis();
    final PhaseOneWriteableTransaction transaction = new PhaseOneWriteableTransaction(importStrategy);
    importedCount.set(0);
@@ -1327,6 +1354,12 @@
      closeSilently(bufferPool);
    }
    /** Tells the storage that the import stopped before it was through, so that its data is not final. */
    void aborted()
    {
      importer.aborted();
    }
    abstract Callable<Void> newPhaseTwoTask(TreeName treeName, Chunk source, PhaseTwoProgressReporter progressReporter);
    void afterPhaseTwo(EntryContainer entryContainer)