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

gbellato
20.54.2007 04ea94b45e747d19ad1bbf105434aab2f889f1ed
Fix for 2244 : null pointer Exception in replication code.

The problem was a missing test for a null value in the case of a
modify operation with a replace with null mod.

I've also added a test for this case.
3 files modified
69 ■■■■■ changed files
opendj-sdk/opends/src/server/org/opends/server/replication/plugin/AttrInfoSingle.java 24 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/replication/plugin/Historical.java 3 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ModifyConflictTest.java 42 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/replication/plugin/AttrInfoSingle.java
@@ -107,7 +107,15 @@
      break;
    case REPLACE:
      deleteTime = addTime = changeNumber;
      if (value == null)
      {
        // REPLACE with null value is actually a DELETE
        deleteTime = changeNumber;
      }
      else
      {
        deleteTime = addTime = changeNumber;
      }
      value = newValue;
      break;
@@ -184,9 +192,17 @@
      }
      else
      {
        addTime = changeNumber;
        value = newValue;
        deleteTime = changeNumber;
        if (newValue == null)
        {
          value = newValue;
          deleteTime = changeNumber;
        }
        else
        {
          addTime = changeNumber;
          value = newValue;
          deleteTime = changeNumber;
        }
      }
      break;
opendj-sdk/opends/src/server/org/opends/server/replication/plugin/Historical.java
@@ -281,7 +281,8 @@
          }
          else if (valInfo.getValueUpdateTime() != null)
          {
            if (delAttr && valInfo.getValueUpdateTime() == deleteTime)
            if ((delAttr && valInfo.getValueUpdateTime() == deleteTime)
               && (valInfo.getValue() != null))
            {
              strValue = type.getNormalizedPrimaryName() + optionsString + ":" +
              valInfo.getValueUpdateTime().toString() +  ":repl:" +
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ModifyConflictTest.java
@@ -161,6 +161,48 @@
               11, false);
  }
  /**
   * Test that replace with null value is corrrectly seen as a delete
   * by doing first a replace with null, then add at at previous time
   * then check that the add was ignored
   */
  @Test()
  public void replaceWithNull() throws Exception
  {
    Entry entry = initializeEntry();
    // load historical from the entry
    Historical hist = Historical.load(entry);
    /*
     * simulate a replace with null done at time t3
     */
    testModify(entry, hist, "displayname", ModificationType.REPLACE, null, 3,
        true);
    /*
     * Now simulate an add at an earlier date that the previous replace. The
     * conflict resolution should detect that this add must be ignored.
     */
    testModify(entry, hist, "displayname", ModificationType.ADD,
        "older value", 1, false);
    /*
     * Now simulate an add at an earlier date that the previous delete. The
     * conflict resolution should detect that this add must be ignored. (a
     * second time to make sure that historical information is kept...)
     */
    testModify(entry, hist, "displayname", ModificationType.ADD,
        "older value", 2, false);
    /*
     * Now simulate an add at a later date that the previous delete.
     * conflict resolution should keep it
     */
    testModify(entry, hist, "displayname", ModificationType.ADD, "new value",
        4, true);
  }
  /**
   * Test that conflict between modify-add and modify-replace for