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

Valery Kharseko
yesterday 0885d16ac22a0ecd2267bf3c8818a3a8a5a9dadb
opendj-server-legacy/src/main/java/org/opends/server/tasks/InitializeTask.java
@@ -13,6 +13,7 @@
 *
 * Copyright 2006-2010 Sun Microsystems, Inc.
 * Portions Copyright 2013-2016 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.opends.server.tasks;
@@ -42,7 +43,15 @@
  private String domainString;
  private int  source;
  private LDAPReplicationDomain domain;
  private TaskState initState;
  /**
   * The monitor used to signal the completion of the import to {@link #runTask()}.
   * <p>
   * A dedicated lock is required because {@link #initState} is reassigned: synchronizing on the
   * state itself would lock the monitor of an enum constant which is both shared JVM wide and
   * different for the waiting and the notifying thread.
   */
  private final Object initStateLock = new Object();
  private volatile TaskState initState;
  /** The total number of entries expected to be processed when this import will end successfully. */
  private long total;
@@ -103,12 +112,12 @@
      // launch the import
      domain.initializeFromRemote(source, this);
      synchronized(initState)
      synchronized (initStateLock)
      {
        // Waiting for the end of the job
        while (initState == TaskState.RUNNING)
        {
          initState.wait(1000);
          initStateLock.wait(1000);
          replaceAttributeValue(ATTR_TASK_INITIALIZE_LEFT, String.valueOf(left));
          replaceAttributeValue(ATTR_TASK_INITIALIZE_DONE, String.valueOf(total-left));
        }
@@ -158,9 +167,9 @@
    finally
    {
      // Wake up runTask method waiting for completion
      synchronized (initState)
      synchronized (initStateLock)
      {
        initState.notify();
        initStateLock.notifyAll();
      }
    }
  }