From 767d37a141a0dbce46eb154f8b67a7a212b20cd8 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Thu, 14 Jun 2007 22:22:08 +0000
Subject: [PATCH] Update the Directory Server schema processing code so that it will detect the case in which there is more than one entry in a schema configuration file (or if there is garbage after the first entry) and log it as a warning message.

---
 opends/src/server/org/opends/server/core/SchemaConfigManager.java |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/SchemaConfigManager.java b/opends/src/server/org/opends/server/core/SchemaConfigManager.java
index 7122e5b..2cb2cc6 100644
--- a/opends/src/server/org/opends/server/core/SchemaConfigManager.java
+++ b/opends/src/server/org/opends/server/core/SchemaConfigManager.java
@@ -865,6 +865,7 @@
       if (entry == null)
       {
         // The file was empty -- skip it.
+        reader.close();
         return new LinkedList<Modification>();
       }
     }
@@ -891,6 +892,32 @@
       }
     }
 
+    // If there are any more entries in the file, then print a warning message.
+    try
+    {
+      Entry e = reader.readEntry(false);
+      if (e != null)
+      {
+        int    msgID   = MSGID_CONFIG_SCHEMA_MULTIPLE_ENTRIES_IN_FILE;
+        String message = getMessage(msgID, schemaFile, schemaDirPath);
+        logError(ErrorLogCategory.SCHEMA, ErrorLogSeverity.SEVERE_WARNING,
+                 message, msgID);
+      }
+    }
+    catch (Exception e)
+    {
+      if (debugEnabled())
+      {
+        TRACER.debugCaught(DebugLogLevel.ERROR, e);
+      }
+
+      int    msgID   = MSGID_CONFIG_SCHEMA_UNPARSEABLE_EXTRA_DATA_IN_FILE;
+      String message = getMessage(msgID, schemaFile, schemaDirPath,
+                                  getExceptionMessage(e));
+      logError(ErrorLogCategory.SCHEMA, ErrorLogSeverity.SEVERE_WARNING,
+               message, msgID);
+    }
+
     try
     {
       reader.close();

--
Gitblit v1.10.0