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

Jean-Noël Rouvignac
27.34.2015 815a836ed89f450f9949d1a40bb99ec3e7889e2e
OPENDJ-2297 OpenDJ 2.x -> 3.0 upgrade fails when there are VLV indexes

JE serializes comparators inside the JE environment.
After upgrade from local-db to pluggable JE backend, we want to remove nearly all databases created with the local-db-backend.
In order to do this, we first need to open the environment and delete databases.
On opening the environment, JE tries to deserialize the comparators.
This fails because the classes in opendj-legacy are not serialization-compatible with the previous classes in opendj-server-legacy.

There were 2 issues that prevented serialization-compatibility:
- *OrderingMatchingRule classes had to implement Serializable
- *OrderingMatchingRule classes were missing the same values for serialVersionUID fields

This fix was successfully tested with a VLV index with the following search filter:
"(&(uid>=user.*)(photo>=*)(numSubordinates<=1)(entryUUID>=*)(modifyTimestamp>=0)(etag>=*)(internationaliSDNNumber>=*))"
This tests the following ordering matches:
"caseIgnoreMatch octetStringMatch integerOrderingMatch uuidOrderingMatch generalizedTimeOrderingMatch caseExactMatch"
Which tests the following ordering matching rule implementations:
"CaseIgnoreOrderingMatchingRule OctetStringOrderingMatchingRule IntegerOrderingMatchingRule UUIDOrderingMatchingRule GeneralizedTimeOrderingMatchingRule CaseExactOrderingMatchingRule NumericStringOrderingMatchingRule"
I am only missing HistoricalCsnOrderingMatchingRule

Note:
When removing the local-db-backend, we will have to move the VLV comparator to the opendj-legacy module.
We can remove all methods, but we will need to retain the serialVersionUID and possibly some fields (to be tested).

*OrderingMatchingRule.java:
Added back serialVersionUID fields.

DummyByteArrayComparator.java:
Implemented Serializable, so all *OrderingMatchingRule classes also do

VLVKeyComparator.java:
During deserialization a NPE was thrown.
10 files modified
43 ■■■■ changed files
opendj-legacy/src/main/java/org/opends/legacy/DummyByteArrayComparator.java 8 ●●●●● patch | view | raw | blame | history
opendj-legacy/src/main/java/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRule.java 4 ●●●● patch | view | raw | blame | history
opendj-legacy/src/main/java/org/opends/server/schema/CaseExactOrderingMatchingRule.java 4 ●●●● patch | view | raw | blame | history
opendj-legacy/src/main/java/org/opends/server/schema/CaseIgnoreOrderingMatchingRule.java 4 ●●●● patch | view | raw | blame | history
opendj-legacy/src/main/java/org/opends/server/schema/GeneralizedTimeOrderingMatchingRule.java 4 ●●●● patch | view | raw | blame | history
opendj-legacy/src/main/java/org/opends/server/schema/IntegerOrderingMatchingRule.java 4 ●●●● patch | view | raw | blame | history
opendj-legacy/src/main/java/org/opends/server/schema/NumericStringOrderingMatchingRule.java 4 ●●●● patch | view | raw | blame | history
opendj-legacy/src/main/java/org/opends/server/schema/OctetStringOrderingMatchingRule.java 4 ●●●● patch | view | raw | blame | history
opendj-legacy/src/main/java/org/opends/server/schema/UUIDOrderingMatchingRule.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/VLVKeyComparator.java 3 ●●●● patch | view | raw | blame | history
opendj-legacy/src/main/java/org/opends/legacy/DummyByteArrayComparator.java
@@ -20,10 +20,11 @@
 *
 * CDDL HEADER END
 *
 *      Copyright 2014 ForgeRock AS
 *      Copyright 2014-2015 ForgeRock AS
 */
package org.opends.legacy;
import java.io.Serializable;
import java.util.Comparator;
/**
@@ -35,12 +36,9 @@
 * @deprecated Do not use
 */
@Deprecated
public class DummyByteArrayComparator implements Comparator<byte[]> {
    /** {@inheritDoc} */
public class DummyByteArrayComparator implements Comparator<byte[]>, Serializable {
    @Override
    public int compare(byte[] o1, byte[] o2) {
        return 0;
    }
}
opendj-legacy/src/main/java/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRule.java
@@ -20,7 +20,7 @@
 *
 * CDDL HEADER END
 *
 *      Copyright 2014 ForgeRock AS
 *      Copyright 2014-2015 ForgeRock AS
 */
package org.opends.server.replication.plugin;
@@ -33,5 +33,5 @@
 */
@Deprecated
public class HistoricalCsnOrderingMatchingRule extends DummyByteArrayComparator {
    // empty
    private static final long serialVersionUID = -3424403930225609943L;
}
opendj-legacy/src/main/java/org/opends/server/schema/CaseExactOrderingMatchingRule.java
@@ -20,7 +20,7 @@
 *
 * CDDL HEADER END
 *
 *      Copyright 2014 ForgeRock AS
 *      Copyright 2014-2015 ForgeRock AS
 */
package org.opends.server.schema;
@@ -33,5 +33,5 @@
 */
@Deprecated
public class CaseExactOrderingMatchingRule extends DummyByteArrayComparator {
    // empty
    private static final long serialVersionUID = -5904188628828913709L;
}
opendj-legacy/src/main/java/org/opends/server/schema/CaseIgnoreOrderingMatchingRule.java
@@ -20,7 +20,7 @@
 *
 * CDDL HEADER END
 *
 *      Copyright 2014 ForgeRock AS
 *      Copyright 2014-2015 ForgeRock AS
 */
package org.opends.server.schema;
@@ -33,5 +33,5 @@
 */
@Deprecated
public class CaseIgnoreOrderingMatchingRule extends DummyByteArrayComparator {
    // empty
    private static final long serialVersionUID = -8992263058903266096L;
}
opendj-legacy/src/main/java/org/opends/server/schema/GeneralizedTimeOrderingMatchingRule.java
@@ -20,7 +20,7 @@
 *
 * CDDL HEADER END
 *
 *      Copyright 2014 ForgeRock AS
 *      Copyright 2014-2015 ForgeRock AS
 */
package org.opends.server.schema;
@@ -33,5 +33,5 @@
 */
@Deprecated
public class GeneralizedTimeOrderingMatchingRule extends DummyByteArrayComparator {
    // empty
    private static final long serialVersionUID = -6343622924726948145L;
}
opendj-legacy/src/main/java/org/opends/server/schema/IntegerOrderingMatchingRule.java
@@ -20,7 +20,7 @@
 *
 * CDDL HEADER END
 *
 *      Copyright 2014 ForgeRock AS
 *      Copyright 2014-2015 ForgeRock AS
 */
package org.opends.server.schema;
@@ -33,5 +33,5 @@
 */
@Deprecated
public class IntegerOrderingMatchingRule extends DummyByteArrayComparator {
    // empty
    private static final long serialVersionUID = 6654300545706161754L;
}
opendj-legacy/src/main/java/org/opends/server/schema/NumericStringOrderingMatchingRule.java
@@ -20,7 +20,7 @@
 *
 * CDDL HEADER END
 *
 *      Copyright 2014 ForgeRock AS
 *      Copyright 2014-2015 ForgeRock AS
 */
package org.opends.server.schema;
@@ -33,5 +33,5 @@
 */
@Deprecated
public class NumericStringOrderingMatchingRule extends DummyByteArrayComparator {
    // empty
    private static final long serialVersionUID = 388436004219363604L;
}
opendj-legacy/src/main/java/org/opends/server/schema/OctetStringOrderingMatchingRule.java
@@ -20,7 +20,7 @@
 *
 * CDDL HEADER END
 *
 *      Copyright 2014 ForgeRock AS
 *      Copyright 2014-2015 ForgeRock AS
 */
package org.opends.server.schema;
@@ -33,5 +33,5 @@
 */
@Deprecated
public class OctetStringOrderingMatchingRule extends DummyByteArrayComparator {
    // empty
    private static final long serialVersionUID = 3832343819704649155L;
}
opendj-legacy/src/main/java/org/opends/server/schema/UUIDOrderingMatchingRule.java
@@ -20,7 +20,7 @@
 *
 * CDDL HEADER END
 *
 *      Copyright 2014 ForgeRock AS
 *      Copyright 2014-2015 ForgeRock AS
 */
package org.opends.server.schema;
@@ -33,5 +33,5 @@
 */
@Deprecated
public class UUIDOrderingMatchingRule extends DummyByteArrayComparator {
    // empty
    private static final long serialVersionUID = -3877941142853469687L;
}
opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/VLVKeyComparator.java
@@ -330,11 +330,10 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void initialize(ClassLoader loader)
  {
    if (orderingRules == null)
    if (orderingRules == null && orderingRuleOids != null)
    {
      orderingRules = new MatchingRule[orderingRuleOids.length];
      for (int i = 0; i < orderingRuleOids.length; i++)