From 3619801f5cfce1e8852b4553b0c4eb4ad19853a8 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Wed, 21 Oct 2026 06:41:55 +0000
Subject: [PATCH] Refuse the local changes in HistoricalCsnOrderingTest only once the missing change publisher of the recovery before has left (#1226)

---
 opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java
index 9a44067..95b2df2 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java
+++ b/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

--
Gitblit v1.10.0