From 6f163823cb9ca5e313699c657bb23dc7b39b586f Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Wed, 27 Nov 2013 07:56:03 +0000
Subject: [PATCH] CR-2635 OPENDJ-1196 updateSchemaFile succeeds if it can't find schema in the templates
---
opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java b/opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java
index 9d77810..acbddac 100644
--- a/opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java
+++ b/opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java
@@ -566,10 +566,14 @@
* is inserted successfully to the destination file.
* @throws IOException
* If an unexpected IO error occurred while reading the entry.
+ * @throws UnknownSchemaElementException
+ * Failure to find an attribute in the template schema indicates
+ * either a programming error (e.g. typo in the attribute name) or
+ * template corruption. Upgrade should stop.
*/
static int updateSchemaFile(final File templateFile, final File destination,
final String[] attributes, final String[] objectClasses)
- throws IOException
+ throws IOException, UnknownSchemaElementException
{
int changeCount = 0;
LDIFEntryReader reader = null;
@@ -582,6 +586,12 @@
{
reader = new LDIFEntryReader(new FileInputStream(templateFile));
+ if (!reader.hasNext())
+ {
+ // Unless template are corrupted, this should not happen.
+ throw new IOException(String.format(
+ "'%s' file is empty. Template corrupted.", templateFile.getName()));
+ }
final LinkedList<String> definitionsList = new LinkedList<String>();
final Entry schemaEntry = reader.readEntry();
@@ -604,6 +614,7 @@
{
LOG.log(Level.SEVERE, ERR_UPGRADE_UNKNOWN_OC_ATT.get("attribute",
att).toString());
+ throw e;
}
}
}
@@ -623,6 +634,7 @@
{
LOG.log(Level.SEVERE, ERR_UPGRADE_UNKNOWN_OC_ATT.get(
"object class", oc).toString());
+ throw e;
}
}
}
--
Gitblit v1.10.0