From 6e7abb4aaf539a4e272daaa13fa9e1ca7c642a52 Mon Sep 17 00:00:00 2001
From: lutoff <lutoff@localhost>
Date: Fri, 05 Dec 2008 10:03:39 +0000
Subject: [PATCH] Fix double extension loading when instance and install are in the directory

---
 opends/src/server/org/opends/server/admin/ClassLoaderProvider.java |   36 ++++++++++++++++++++++++++++++------
 1 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/opends/src/server/org/opends/server/admin/ClassLoaderProvider.java b/opends/src/server/org/opends/server/admin/ClassLoaderProvider.java
index 99cb790..d64835c 100644
--- a/opends/src/server/org/opends/server/admin/ClassLoaderProvider.java
+++ b/opends/src/server/org/opends/server/admin/ClassLoaderProvider.java
@@ -318,15 +318,39 @@
     // First load the extension from the install directory, then
     // from the instance directory.
     File libDir ;
-    File extensionsPath ;
+    File installExtensionsPath ;
+    File instanceExtensionsPath ;
 
-    libDir = new File(DirectoryServer.getServerRoot(),LIB_DIR);
-    extensionsPath = new File(libDir, EXTENSIONS_DIR);
-    initializeAllExtensions(extensionsPath);
 
+    // load install dir extension
+    libDir = new File(DirectoryServer.getServerRoot(), LIB_DIR);
+    try
+    {
+      installExtensionsPath =
+        new File(libDir, EXTENSIONS_DIR).getCanonicalFile();
+    }
+    catch (Exception e)
+    {
+      installExtensionsPath = new File(libDir, EXTENSIONS_DIR);
+    }
+    initializeAllExtensions(installExtensionsPath);
+
+    // load instance dir extension
     libDir = new File(DirectoryServer.getInstanceRoot(),LIB_DIR);
-    extensionsPath = new File(libDir, EXTENSIONS_DIR);
-    initializeAllExtensions(extensionsPath);
+    try
+    {
+      instanceExtensionsPath =
+        new File(libDir, EXTENSIONS_DIR).getCanonicalFile();
+    }
+    catch (Exception e)
+    {
+      instanceExtensionsPath = new File(libDir, EXTENSIONS_DIR);
+    }
+    if (! installExtensionsPath.getAbsolutePath().equals(
+        instanceExtensionsPath.getAbsolutePath()))
+    {
+      initializeAllExtensions(instanceExtensionsPath);
+    }
   }
 
 

--
Gitblit v1.10.0