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

Valery Kharseko
yesterday 3619801f5cfce1e8852b4553b0c4eb4ad19853a8
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java
@@ -2810,10 +2810,31 @@
   * server misses some, up to the pending changes leaving them to the recovery: they are recorded in
   * the domain state only, and the replication server misses them. The recovery the next session
   * starts rebuilds them from the historical information.
   * <p>
   * Once the missing change publisher of an earlier session has left, under the lock it leaves under:
   * it has the broker take the local changes again as it leaves, after the end of its recovery - which
   * is all {@link #waitUntilTheRecoveryIsOver(LDAPReplicationDomain)} waits for - and the replication
   * server would get the changes the test has it miss.
   */
  private static void refuseTheLocalChanges(LDAPReplicationDomain domain) throws Exception
  private static void refuseTheLocalChanges(final LDAPReplicationDomain domain) throws Exception
  {
    brokerOf(domain).setRecoveryRequired(true);
    final Field recoveryLockField = LDAPReplicationDomain.class.getDeclaredField("recoveryLock");
    recoveryLockField.setAccessible(true);
    final Object recoveryLock = recoveryLockField.get(domain);
    final Field publisherField = LDAPReplicationDomain.class.getDeclaredField("rsUpdater");
    publisherField.setAccessible(true);
    new TestTimer.Builder()
        .maxSleep(30, SECONDS)
        .sleepTimes(100, MILLISECONDS)
        .toTimer()
        .repeatUntilSuccess(() ->
        {
          synchronized (recoveryLock)
          {
            assertNull(publisherField.get(domain), "the missing change publisher of an earlier session has left");
            brokerOf(domain).setRecoveryRequired(true);
          }
        });
  }
  private static PendingChanges pendingChangesOf(LDAPReplicationDomain domain) throws Exception