From 4aeaf5775f4edc7af87aa33058ae3db25d27f9a9 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 23 Jun 2016 13:59:36 +0000
Subject: [PATCH] OPENDJ-3149 Upgrade 3.0.0 -> 4.0.0: Error in logs after upgrading a replication topology
---
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java | 42 +++++++++++++++++++++++++++++++++++++++---
1 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
index 2953dbb..7f8a556 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -800,7 +800,7 @@
for (ByteString v : a)
{
AttributeType type = newSchema.parseAttributeType(v.toString());
- removeAttributeType(type, newSchema, modifiedSchemaFiles);
+ removeAttributeType(type, newSchema, mods, pos, modifiedSchemaFiles);
}
}
else if (at.equals(objectClassesType))
@@ -1108,8 +1108,8 @@
* the provided attribute type from the server
* schema.
*/
- private void removeAttributeType(AttributeType attributeType, Schema schema, Set<String> modifiedSchemaFiles)
- throws DirectoryException
+ private void removeAttributeType(AttributeType attributeType, Schema schema, List<Modification> modifications,
+ int currentPosition, Set<String> modifiedSchemaFiles) throws DirectoryException
{
// See if the specified attribute type is actually defined in the server
// schema. If not, then fail.
@@ -1121,6 +1121,42 @@
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
}
+ // See if there is another modification later to add the attribute type back
+ // into the schema. If so, then it's a replace and we should ignore the
+ // remove because adding it back will handle the replace.
+ for (int i = currentPosition + 1; i < modifications.size(); i++)
+ {
+ Modification m = modifications.get(i);
+ Attribute a = m.getAttribute();
+
+ if (m.getModificationType() != ModificationType.ADD
+ || !a.getAttributeDescription().getAttributeType().equals(attributeTypesType))
+ {
+ continue;
+ }
+
+ for (ByteString v : a)
+ {
+ String oid;
+ try
+ {
+ oid = Schema.parseOID(v.toString(), ERR_PARSING_ATTRIBUTE_TYPE_OID);
+ }
+ catch (DirectoryException de)
+ {
+ logger.traceException(de);
+ throw de;
+ }
+
+ if (attributeType.getOID().equals(oid))
+ {
+ // We found a match where the attribute type is added back later,
+ // so we don't need to do anything else here.
+ return;
+ }
+ }
+ }
+
// Make sure that the attribute type isn't used as the superior type for
// any other attributes.
for (AttributeType at : schema.getAttributeTypes())
--
Gitblit v1.10.0