From e7a3a910de35ad3d576f09a738a4c1512ff5913c Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Fri, 16 Jan 2015 07:35:30 +0000
Subject: [PATCH] OPENDJ-1645 CR-5805 Use name instead of oid to for hash code of schema elements

---
 opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestCommonSchemaElements.java |    6 +++---
 opendj3-server-dev/src/server/org/opends/server/types/CommonSchemaElements.java                             |    9 +++++----
 opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestObjectClass.java          |    2 +-
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/types/CommonSchemaElements.java b/opendj3-server-dev/src/server/org/opends/server/types/CommonSchemaElements.java
index 681e507..ec7aada 100644
--- a/opendj3-server-dev/src/server/org/opends/server/types/CommonSchemaElements.java
+++ b/opendj3-server-dev/src/server/org/opends/server/types/CommonSchemaElements.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2006-2009 Sun Microsystems, Inc.
- *      Portions Copyright 2013-2014 ForgeRock AS
+ *      Portions Copyright 2013-2015 ForgeRock AS
  */
 package org.opends.server.types;
 
@@ -145,8 +145,6 @@
     this.description = description;
     this.isObsolete = isObsolete;
 
-    hashCode = oid.hashCode();
-
     // Make sure we have a primary name if possible.
     if (primaryName == null) {
       if (names != null && !names.isEmpty()) {
@@ -159,6 +157,9 @@
     }
     this.lowerName = toLowerCase(primaryName);
 
+    // OPENDJ-1645: oid changes during server bootstrap, so prefer using name if available
+    hashCode = getNameOrOID().hashCode();
+
     // Construct the normalized attribute name mapping.
     if (names != null) {
       this.names = new LinkedHashMap<String, String>(names.size());
@@ -525,7 +526,7 @@
 
     if (o instanceof CommonSchemaElements) {
       CommonSchemaElements other = (CommonSchemaElements) o;
-      return oid.equals(other.oid);
+      return getNameOrOID().equals(other.getNameOrOID());
     }
 
     return false;
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestCommonSchemaElements.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestCommonSchemaElements.java
index d1ee16d..5735360 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestCommonSchemaElements.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestCommonSchemaElements.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2006-2008 Sun Microsystems, Inc.
- *      Portions Copyright 2014 ForgeRock AS
+ *      Portions Copyright 2014-2015 ForgeRock AS
  */
 package org.opends.server.types;
 
@@ -351,8 +351,8 @@
   public final Object[][] createEqualsTestData() {
     return new Object[][] {
         { "testType", "1.2.3", "testType", "1.2.3", true },
-        { "testType", "1.2.3", "xxx", "1.2.3", true },
-        { "testType", "1.2.3", "testType", "1.2.4", false },
+        { "testType", "1.2.3", "xxx", "1.2.3", false },
+        { "testType", "1.2.3", "testType", "1.2.4", true },
         { "testType", "1.2.3", "xxx", "1.2.4", false } };
   }
 
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestObjectClass.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestObjectClass.java
index 1cec884..23b49f9 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestObjectClass.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestObjectClass.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2006-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2013-2014 ForgeRock AS
+ *      Portions Copyright 2013-2015 ForgeRock AS
  */
 package org.opends.server.types;
 

--
Gitblit v1.10.0