From 4497ef71d990f2bdc879b57c08b69f4bf79960bc Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Tue, 27 Nov 2007 07:52:20 +0000
Subject: [PATCH] Fix for 2565 Java Exception during conflict resolution   In this particular case of conflict resolution, the newSuperior was null and this was causing some Exception. The solution is simply to test for this condition and generate a conflict.  Also added a unit test for this particular case.

---
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java |   31 +++++++++++++++++++++++++++++++
 opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java                    |   12 ++++++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java b/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
index 1422ef8..c7d71d1 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
@@ -1772,6 +1772,18 @@
     return true;
   }
 
+  // If we could not find the new parent entry, we missed this entry
+  // earlier or it has disappeared from the database
+  // Log this information for the repair tool and mark the entry
+  // as conflicting.
+  // stop the processing.
+  if (newSuperior == null)
+  {
+    markConflictEntry(op, currentDN, newDN);
+    numUnresolvedNamingConflicts.incrementAndGet();
+    return true;
+  }
+
   if ((result == ResultCode.NO_SUCH_OBJECT) ||
       (result == ResultCode.OBJECTCLASS_VIOLATION))
   {
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
index 9608f6c..58395af 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
@@ -1191,6 +1191,37 @@
     assertEquals(DummyAlertHandler.getAlertCount(), AlertCount,
         "An alert was incorrectly generated when resolving conflicts");
 
+    /*
+     * Check that a conflict is detected when an entry is 
+     * moved below an entry that does not exist.
+     */
+    updateMonitorCount(baseDn, unresolvedMonitorAttr);
+    AlertCount = DummyAlertHandler.getAlertCount();
+    modDnMsg = new ModifyDNMsg(
+        "uid=new person,ou=People,dc=example,dc=com", gen.newChangeNumber(),
+        "33333333-3333-3333-3333-333333333333",
+        "12343333-3533-3633-3333-333333833333" , false,
+        "uid=wrong, ou=people,dc=example,dc=com",
+        "uid=newrdn");
+    broker.publish(modDnMsg);
+    
+    count = 0;
+    while ((count<2000) && getMonitorDelta() == 0)
+    {
+      // it is possible that the update has not yet been applied
+      // wait a short time and try again.
+      Thread.sleep(100);
+      count++;
+    }
+    // if the monitor counter did not get incremented after 200sec
+    // then something got wrong.
+    assertTrue(count < 200);
+    
+    // check that the entry have been correctly marked as conflicting.
+    assertTrue(checkEntryHasAttribute(
+        DN.decode("uid=new person,ou=baseDn2,"+baseDn),
+        ReplicationDomain.DS_SYNC_CONFLICT,
+        "uid=newrdn,ou=People,dc=example,dc=com", 1000, true));
     
     broker.stop();
   }

--
Gitblit v1.10.0