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

gbellato
27.52.2007 4497ef71d990f2bdc879b57c08b69f4bf79960bc
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.
2 files modified
43 ■■■■■ changed files
opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java 12 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java 31 ●●●●● patch | view | raw | blame | history
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))
  {
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();
  }