[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Pki-devel] [PATCH] 613 Fixed thread leaks during shutdown.



Various codes have been modified to properly stop threads during
shutdown. A new ID attribute has been added to the LDAP connection
factory classes to help identify leaking threads.

https://fedorahosted.org/pki/ticket/1327

--
Endi S. Dewata
From 1e6df72e52ee8a643cb85730f0e512b0cd5d73c4 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata redhat com>
Date: Tue, 16 Jun 2015 14:12:54 -0400
Subject: [PATCH] Fixed thread leaks during shutdown.

Various codes have been modified to properly stop threads during
shutdown. A new ID attribute has been added to the LDAP connection
factory classes to help identify leaking threads.

https://fedorahosted.org/pki/ticket/1327
---
 .../server/ca/rest/CAInstallerService.java         |  2 +-
 base/common/src/com/netscape/certsrv/apps/CMS.java | 12 +++++------
 .../src/com/netscape/certsrv/apps/ICMSEngine.java  |  6 +++---
 .../certsrv/base/ISecurityDomainSessionTable.java  |  2 ++
 .../cms/authentication/DirBasedAuthentication.java |  2 +-
 .../netscape/cms/authentication/PortalEnroll.java  |  2 +-
 .../authentication/UidPwdPinDirAuthentication.java |  2 +-
 .../netscape/cms/authorization/DirAclAuthz.java    |  2 +-
 .../netscape/cms/listeners/PinRemovalListener.java |  2 +-
 .../cms/src/com/netscape/cms/logging/LogFile.java  | 16 +++++++++------
 .../com/netscape/cms/logging/RollingLogFile.java   | 20 ++++++++++++------
 .../constraints/AttributePresentConstraints.java   |  2 +-
 .../cms/profile/def/nsNKeySubjectNameDefault.java  |  2 +-
 .../def/nsTokenUserKeySubjectNameDefault.java      |  2 +-
 .../publish/publishers/LdapCaCertPublisher.java    |  2 +-
 .../cms/publish/publishers/LdapCrlPublisher.java   |  2 +-
 .../publish/publishers/LdapUserCertPublisher.java  |  2 +-
 .../cms/servlet/csadmin/ConfigurationUtils.java    | 16 +++++++--------
 .../servlet/csadmin/SecurityDomainProcessor.java   |  2 +-
 .../cms/servlet/csadmin/UpdateDomainXML.java       |  6 +++---
 .../src/com/netscape/cmscore/apps/CMSEngine.java   | 18 +++++++++++-----
 .../authentication/PasswdUserDBAuthentication.java |  5 +++--
 .../cmscore/cert/CrossCertPairSubsystem.java       |  2 +-
 .../src/com/netscape/cmscore/dbs/DBSubsystem.java  |  2 +-
 .../com/netscape/cmscore/ldap/LdapConnModule.java  |  2 +-
 .../netscape/cmscore/ldap/LdapPublishModule.java   |  4 ++--
 .../cmscore/ldapconn/LdapAnonConnFactory.java      | 16 ++++++++++++---
 .../cmscore/ldapconn/LdapBoundConnFactory.java     | 18 +++++++++++++---
 .../src/com/netscape/cmscore/logging/LogQueue.java |  9 ++++----
 .../cmscore/profile/LDAPProfileSubsystem.java      |  2 +-
 .../cmscore/selftests/SelfTestSubsystem.java       |  2 ++
 .../session/LDAPSecurityDomainSessionTable.java    | 10 ++++++++-
 .../session/SecurityDomainSessionTable.java        |  3 +++
 .../com/netscape/cmscore/usrgrp/UGSubsystem.java   |  2 +-
 .../src/com/netscape/cmscore/util/Debug.java       | 24 ++++++----------------
 .../netscape/cmscore/app/CMSEngineDefaultStub.java |  6 +++---
 36 files changed, 137 insertions(+), 92 deletions(-)

diff --git a/base/ca/src/org/dogtagpki/server/ca/rest/CAInstallerService.java b/base/ca/src/org/dogtagpki/server/ca/rest/CAInstallerService.java
index 355e744a338004f8d4c555738cac7a901377e6bb..e1b71604d69c7485c8112dc947860e9a6a3f2363 100644
--- a/base/ca/src/org/dogtagpki/server/ca/rest/CAInstallerService.java
+++ b/base/ca/src/org/dogtagpki/server/ca/rest/CAInstallerService.java
@@ -125,7 +125,7 @@ public class CAInstallerService extends SystemConfigService {
         StringTokenizer st = new StringTokenizer(profileIds, ",");
 
         IConfigStore dbCfg = cs.getSubStore("internaldb");
-        ILdapConnFactory dbFactory = CMS.getLdapBoundConnFactory();
+        ILdapConnFactory dbFactory = CMS.getLdapBoundConnFactory("CAInstallerService");
         dbFactory.init(dbCfg);
 
         while (st.hasMoreTokens()) {
diff --git a/base/common/src/com/netscape/certsrv/apps/CMS.java b/base/common/src/com/netscape/certsrv/apps/CMS.java
index e301e20ef033002ca0a1115529b6cedfee650f74..3ba6d75779afa73dc7f96fe69643e5c7c86ff8de 100644
--- a/base/common/src/com/netscape/certsrv/apps/CMS.java
+++ b/base/common/src/com/netscape/certsrv/apps/CMS.java
@@ -626,10 +626,10 @@ public final class CMS {
         return _engine.getUserMessage(null /* from session context */, msgID, p1, p2, p3);
     }
 
-    public static LDAPConnection getBoundConnection(String host, int port,
+    public static LDAPConnection getBoundConnection(String id, String host, int port,
                int version, LDAPSSLSocketFactoryExt fac, String bindDN,
                String bindPW) throws LDAPException {
-        return _engine.getBoundConnection(host, port, version, fac,
+        return _engine.getBoundConnection(id, host, port, version, fac,
                          bindDN, bindPW);
     }
 
@@ -1330,9 +1330,9 @@ public final class CMS {
      *
      * @return bound LDAP connection pool
      */
-    public static ILdapConnFactory getLdapBoundConnFactory()
+    public static ILdapConnFactory getLdapBoundConnFactory(String id)
             throws ELdapException {
-        return _engine.getLdapBoundConnFactory();
+        return _engine.getLdapBoundConnFactory(id);
     }
 
     /**
@@ -1340,9 +1340,9 @@ public final class CMS {
      *
      * @return anonymous LDAP connection pool
      */
-    public static ILdapConnFactory getLdapAnonConnFactory()
+    public static ILdapConnFactory getLdapAnonConnFactory(String id)
             throws ELdapException {
-        return _engine.getLdapAnonConnFactory();
+        return _engine.getLdapAnonConnFactory(id);
     }
 
     /**
diff --git a/base/common/src/com/netscape/certsrv/apps/ICMSEngine.java b/base/common/src/com/netscape/certsrv/apps/ICMSEngine.java
index b90c739970e993d5d46ba10b16e1bafd8836ba0a..57c2b6cb0dda60263613b02f07494e8c255fa74c 100644
--- a/base/common/src/com/netscape/certsrv/apps/ICMSEngine.java
+++ b/base/common/src/com/netscape/certsrv/apps/ICMSEngine.java
@@ -640,9 +640,9 @@ public interface ICMSEngine extends ISubsystem {
      *
      * @return bound LDAP connection pool
      */
-    public ILdapConnFactory getLdapBoundConnFactory() throws ELdapException;
+    public ILdapConnFactory getLdapBoundConnFactory(String id) throws ELdapException;
 
-    public LDAPConnection getBoundConnection(String host, int port,
+    public LDAPConnection getBoundConnection(String id, String host, int port,
                int version, LDAPSSLSocketFactoryExt fac, String bindDN,
                String bindPW) throws LDAPException;
 
@@ -651,7 +651,7 @@ public interface ICMSEngine extends ISubsystem {
      *
      * @return anonymous LDAP connection pool
      */
-    public ILdapConnFactory getLdapAnonConnFactory() throws ELdapException;
+    public ILdapConnFactory getLdapAnonConnFactory(String id) throws ELdapException;
 
     /**
      * Retrieves the password check.
diff --git a/base/common/src/com/netscape/certsrv/base/ISecurityDomainSessionTable.java b/base/common/src/com/netscape/certsrv/base/ISecurityDomainSessionTable.java
index 24c55d08602a890e78ac86d812dc894e86932405..9bf3aa24bb655a146a5c7dedb16960183464f205 100644
--- a/base/common/src/com/netscape/certsrv/base/ISecurityDomainSessionTable.java
+++ b/base/common/src/com/netscape/certsrv/base/ISecurityDomainSessionTable.java
@@ -45,4 +45,6 @@ public interface ISecurityDomainSessionTable {
     public long getTimeToLive();
 
     public Enumeration<String> getSessionIds();
+
+    public void shutdown();
 }
diff --git a/base/server/cms/src/com/netscape/cms/authentication/DirBasedAuthentication.java b/base/server/cms/src/com/netscape/cms/authentication/DirBasedAuthentication.java
index 78aa399b41263c3da1b050f1729eb48157d730e4..a8a95284df14bd287f7a9a0f5ccba43bf174c4a8 100644
--- a/base/server/cms/src/com/netscape/cms/authentication/DirBasedAuthentication.java
+++ b/base/server/cms/src/com/netscape/cms/authentication/DirBasedAuthentication.java
@@ -277,7 +277,7 @@ public abstract class DirBasedAuthentication
             mGroupUserIDName = mLdapConfig.getString(PROP_GROUP_USERID_NAME, "cn");
             CMS.debug("DirBasedAuthentication: mGroupUserIDName="+ mGroupUserIDName);
         }
-        mConnFactory = CMS.getLdapAnonConnFactory();
+        mConnFactory = CMS.getLdapAnonConnFactory("DirBasedAuthentication");
         mConnFactory.init(mLdapConfig);
 
         /* initialize dn pattern */
diff --git a/base/server/cms/src/com/netscape/cms/authentication/PortalEnroll.java b/base/server/cms/src/com/netscape/cms/authentication/PortalEnroll.java
index c94cec6172c11ade721d4f8b3bf8bd971c6b8cf5..46ce65f76205d2662c43d202d853b72af1bba24b 100644
--- a/base/server/cms/src/com/netscape/cms/authentication/PortalEnroll.java
+++ b/base/server/cms/src/com/netscape/cms/authentication/PortalEnroll.java
@@ -152,7 +152,7 @@ public class PortalEnroll extends DirBasedAuthentication {
             throw new EPropertyNotFound(CMS.getUserMessage("CMS_BASE_GET_PROPERTY_FAILED", "objectclass"));
 
         /* Get connect parameter */
-        mLdapFactory = CMS.getLdapBoundConnFactory();
+        mLdapFactory = CMS.getLdapBoundConnFactory("PortalEnroll");
         mLdapFactory.init(mLdapConfig);
         mLdapConn = mLdapFactory.getConn();
 
diff --git a/base/server/cms/src/com/netscape/cms/authentication/UidPwdPinDirAuthentication.java b/base/server/cms/src/com/netscape/cms/authentication/UidPwdPinDirAuthentication.java
index 9e551966c3307f9b4a358c7ebd7dc60ed15b1f38..ed20740530b303b895372390c8c9ce8a40ff633d 100644
--- a/base/server/cms/src/com/netscape/cms/authentication/UidPwdPinDirAuthentication.java
+++ b/base/server/cms/src/com/netscape/cms/authentication/UidPwdPinDirAuthentication.java
@@ -157,7 +157,7 @@ public class UidPwdPinDirAuthentication extends DirBasedAuthentication
 
         if (mRemovePin) {
             removePinLdapConfigStore = config.getSubStore("ldap");
-            removePinLdapFactory = CMS.getLdapBoundConnFactory();
+            removePinLdapFactory = CMS.getLdapBoundConnFactory("UidPwdPinDirAuthentication");
             removePinLdapFactory.init(removePinLdapConfigStore);
             removePinLdapConnection = removePinLdapFactory.getConn();
         }
diff --git a/base/server/cms/src/com/netscape/cms/authorization/DirAclAuthz.java b/base/server/cms/src/com/netscape/cms/authorization/DirAclAuthz.java
index d0677875c3a69c520d8569646b720df6f624ae62..bdf3f5e9c823ebc64ac046fab3d08af678893f8a 100644
--- a/base/server/cms/src/com/netscape/cms/authorization/DirAclAuthz.java
+++ b/base/server/cms/src/com/netscape/cms/authorization/DirAclAuthz.java
@@ -143,7 +143,7 @@ public class DirAclAuthz extends AAclAuthz
                 return;
         }
 
-        mLdapConnFactory = CMS.getLdapBoundConnFactory();
+        mLdapConnFactory = CMS.getLdapBoundConnFactory("DirAclAuthz");
         mLdapConnFactory.init(ldapConfig);
 
         // retrieve aclResources from the LDAP server and load
diff --git a/base/server/cms/src/com/netscape/cms/listeners/PinRemovalListener.java b/base/server/cms/src/com/netscape/cms/listeners/PinRemovalListener.java
index 21d69e29d21ce6c7d238a061b29569834bcb3670..dbe03ce6f6bef6be64af19df849a25bc78782e42 100644
--- a/base/server/cms/src/com/netscape/cms/listeners/PinRemovalListener.java
+++ b/base/server/cms/src/com/netscape/cms/listeners/PinRemovalListener.java
@@ -95,7 +95,7 @@ public class PinRemovalListener implements IRequestListener {
         mConfig = config;
 
         mLdapConfig = mConfig.getSubStore(PROP_LDAP);
-        mConnFactory = CMS.getLdapBoundConnFactory();
+        mConnFactory = CMS.getLdapBoundConnFactory("PinRemovalListener");
         mConnFactory.init(mLdapConfig);
         mRemovePinLdapConnection = mConnFactory.getConn();
 
diff --git a/base/server/cms/src/com/netscape/cms/logging/LogFile.java b/base/server/cms/src/com/netscape/cms/logging/LogFile.java
index c465a4e53e25fede60327f0c3fc6bf2ce6ec2b59..9d19eddc6e3b3521a512780708a7274b344b369a 100644
--- a/base/server/cms/src/com/netscape/cms/logging/LogFile.java
+++ b/base/server/cms/src/com/netscape/cms/logging/LogFile.java
@@ -519,6 +519,8 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo {
         if (fileName == null)
             throw new ELogException(CMS.getUserMessage("CMS_LOG_INVALID_FILE_NAME", "null"));
 
+        CMS.debug("Creating " + getClass().getSimpleName() + "(" + fileName + ")");
+
         //If we want to reuse the old log files
         //mFileName = fileName + "." + mLogFileDateFormat.format(mDate);
         mFileName = fileName;
@@ -863,10 +865,11 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo {
      * </ul>
      */
     public synchronized void shutdown() {
+
+        CMS.debug("Destroying LogFile(" + mFileName + ")");
+
         String auditMessage = null;
 
-        CMS.debug("LogFile:In log shutdown");
-
         setFlushInterval(0);
 
         // log signed audit shutdown success
@@ -891,10 +894,13 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo {
     public synchronized void setFlushInterval(int flushInterval) {
         mFlushInterval = flushInterval * 1000;
 
-        if ((mFlushThread == null) && (mFlushInterval > 0)) {
+        if (mFlushThread == null && mFlushInterval > 0) {
             mFlushThread = new FlushThread();
             mFlushThread.setDaemon(true);
             mFlushThread.start();
+
+        } else if (mFlushThread != null && mFlushInterval == 0) {
+            mFlushThread.interrupt();
         }
 
         this.notify();
@@ -921,9 +927,7 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo {
                     try {
                         LogFile.this.wait(mFlushInterval);
                     } catch (InterruptedException e) {
-                        // This shouldn't happen very often
-                        ConsoleError.send(new
-                                SystemEvent(CMS.getUserMessage("CMS_LOG_THREAD_INTERRUPT", "flush")));
+                        // shutdown
                     }
                 }
 
diff --git a/base/server/cms/src/com/netscape/cms/logging/RollingLogFile.java b/base/server/cms/src/com/netscape/cms/logging/RollingLogFile.java
index 0a7a9f0986a6052877178ecc1b09b0043155d868..32568dac053b6ff2bc2e5d11983fc6ba55db552e 100644
--- a/base/server/cms/src/com/netscape/cms/logging/RollingLogFile.java
+++ b/base/server/cms/src/com/netscape/cms/logging/RollingLogFile.java
@@ -139,6 +139,7 @@ public class RollingLogFile extends LogFile {
      * Shutdown this log file.
      */
     public synchronized void shutdown() {
+        CMS.debug("Destroying RollingLogFile(" + mFileName + ")");
         setRolloverTime("0");
         setExpirationTime("0");
         super.shutdown();
@@ -157,6 +158,9 @@ public class RollingLogFile extends LogFile {
             mRolloverThread = new RolloverThread();
             mRolloverThread.setDaemon(true);
             mRolloverThread.start();
+
+        } else if (mRolloverThread != null && mRolloverInterval == 0) {
+            mRolloverThread.interrupt();
         }
 
         this.notify();
@@ -190,6 +194,10 @@ public class RollingLogFile extends LogFile {
                     mExpirationThread.setDaemon(true);
                     mExpirationThread.start();
                 }
+
+            } else if (mExpirationThread != null && mExpirationTime == 0) {
+                mExpirationThread.interrupt();
+
             } else {
                 mExpLock.notify();
             }
@@ -401,9 +409,7 @@ public class RollingLogFile extends LogFile {
                     try {
                         RollingLogFile.this.wait(mRolloverInterval);
                     } catch (InterruptedException e) {
-                        // This shouldn't happen very often
-                        CMS.getLogger().getLogQueue().log(new
-                                SystemEvent(CMS.getUserMessage("CMS_LOG_THREAD_INTERRUPT", "rollover")));
+                        // shutdown
                     }
                 }
 
@@ -475,11 +481,13 @@ public class RollingLogFile extends LogFile {
                         try {
                             mExpLock.wait(sleepTime);
                         } catch (InterruptedException e) {
-                            // This shouldn't happen very often
-                            ConsoleError.send(new
-                                    SystemEvent(CMS.getUserMessage("CMS_LOG_THREAD_INTERRUPT", "expiration")));
+                            // shutdown
                         }
                     }
+
+                    if (mExpirationTime == 0) {
+                        break;
+                    }
                 }
             }
             mExpirationThread = null;
diff --git a/base/server/cms/src/com/netscape/cms/policy/constraints/AttributePresentConstraints.java b/base/server/cms/src/com/netscape/cms/policy/constraints/AttributePresentConstraints.java
index e12b8220fa35ec5d341535d21f8eeab9fc520a9b..fb56c67c42211d9fbd130c39f34d39310a6d77b2 100644
--- a/base/server/cms/src/com/netscape/cms/policy/constraints/AttributePresentConstraints.java
+++ b/base/server/cms/src/com/netscape/cms/policy/constraints/AttributePresentConstraints.java
@@ -257,7 +257,7 @@ public class AttributePresentConstraints extends APolicyRule
 
         mLdapConfig = mConfig.getSubStore(PROP_LDAP);
 
-        mConnFactory = CMS.getLdapBoundConnFactory();
+        mConnFactory = CMS.getLdapBoundConnFactory("AttributePresentConstraints");
         mConnFactory.init(mLdapConfig);
         mCheckAttrLdapConnection = mConnFactory.getConn();
 
diff --git a/base/server/cms/src/com/netscape/cms/profile/def/nsNKeySubjectNameDefault.java b/base/server/cms/src/com/netscape/cms/profile/def/nsNKeySubjectNameDefault.java
index c90b76c5dbad504fd127fc0137e53ec56c95d4fa..49e951ae362ac79d838456285c25b28f5372841b 100644
--- a/base/server/cms/src/com/netscape/cms/profile/def/nsNKeySubjectNameDefault.java
+++ b/base/server/cms/src/com/netscape/cms/profile/def/nsNKeySubjectNameDefault.java
@@ -264,7 +264,7 @@ public class nsNKeySubjectNameDefault extends EnrollDefault {
             mParamsConfig = mInstConfig.getSubStore(PROP_PARAMS);
             mLdapConfig = mParamsConfig.getSubStore(PROP_LDAP);
             mBaseDN = mParamsConfig.getString(CONFIG_LDAP_BASEDN, null);
-            mConnFactory = CMS.getLdapAnonConnFactory();
+            mConnFactory = CMS.getLdapAnonConnFactory("nsNKeySubjectNameDefault");
             mConnFactory.init(mLdapConfig);
 
             /* initialize dn pattern */
diff --git a/base/server/cms/src/com/netscape/cms/profile/def/nsTokenUserKeySubjectNameDefault.java b/base/server/cms/src/com/netscape/cms/profile/def/nsTokenUserKeySubjectNameDefault.java
index 86a2a696129ce2fe1b513b5c30e60aa14d6ba57b..0a8d9db906be0b12b58748c5eabbfa38a95020f9 100644
--- a/base/server/cms/src/com/netscape/cms/profile/def/nsTokenUserKeySubjectNameDefault.java
+++ b/base/server/cms/src/com/netscape/cms/profile/def/nsTokenUserKeySubjectNameDefault.java
@@ -287,7 +287,7 @@ public class nsTokenUserKeySubjectNameDefault extends EnrollDefault {
                 return;
 
             mBaseDN = mParamsConfig.getString(CONFIG_LDAP_BASEDN, null);
-            mConnFactory = CMS.getLdapAnonConnFactory();
+            mConnFactory = CMS.getLdapAnonConnFactory("nsTokenUserKeySubjectNameDefault");
             mConnFactory.init(mLdapConfig);
 
             /* initialize dn pattern */
diff --git a/base/server/cms/src/com/netscape/cms/publish/publishers/LdapCaCertPublisher.java b/base/server/cms/src/com/netscape/cms/publish/publishers/LdapCaCertPublisher.java
index 06050480e913997f1d934a41506776efcb24551f..f740ef3c42efa2fcb1c2adc69ac04e5f64e5f632 100644
--- a/base/server/cms/src/com/netscape/cms/publish/publishers/LdapCaCertPublisher.java
+++ b/base/server/cms/src/com/netscape/cms/publish/publishers/LdapCaCertPublisher.java
@@ -186,7 +186,7 @@ public class LdapCaCertPublisher
                 String mgr_dn = mConfig.getString("bindDN", null);
                 String mgr_pwd = mConfig.getString("bindPWD", null);
 
-                altConn = CMS.getBoundConnection(host, portVal,
+                altConn = CMS.getBoundConnection("LdapCaCertPublisher", host, portVal,
                         version,
                         sslSocket, mgr_dn, mgr_pwd);
                 conn = altConn;
diff --git a/base/server/cms/src/com/netscape/cms/publish/publishers/LdapCrlPublisher.java b/base/server/cms/src/com/netscape/cms/publish/publishers/LdapCrlPublisher.java
index 9173f3cdf3915c5997781b0449393ac1b8d9adcf..80ffa3c4bc687735e909c927a623262ee810c390 100644
--- a/base/server/cms/src/com/netscape/cms/publish/publishers/LdapCrlPublisher.java
+++ b/base/server/cms/src/com/netscape/cms/publish/publishers/LdapCrlPublisher.java
@@ -177,7 +177,7 @@ public class LdapCrlPublisher implements ILdapPublisher, IExtendedPluginInfo {
                 String mgr_dn = mConfig.getString("bindDN", null);
                 String mgr_pwd = mConfig.getString("bindPWD", null);
 
-                altConn = CMS.getBoundConnection(host, portVal,
+                altConn = CMS.getBoundConnection("LdapCrlPublisher", host, portVal,
                         version,
                         sslSocket, mgr_dn, mgr_pwd);
                 conn = altConn;
diff --git a/base/server/cms/src/com/netscape/cms/publish/publishers/LdapUserCertPublisher.java b/base/server/cms/src/com/netscape/cms/publish/publishers/LdapUserCertPublisher.java
index 020c255522b5185631b1c8830cf20de4d296b78f..a01cf80d1a6e988d48cceb49e0fe014fb6e62bb3 100644
--- a/base/server/cms/src/com/netscape/cms/publish/publishers/LdapUserCertPublisher.java
+++ b/base/server/cms/src/com/netscape/cms/publish/publishers/LdapUserCertPublisher.java
@@ -141,7 +141,7 @@ public class LdapUserCertPublisher implements ILdapPublisher, IExtendedPluginInf
                 String mgr_dn = mConfig.getString("bindDN", null);
                 String mgr_pwd = mConfig.getString("bindPWD", null);
 
-                altConn = CMS.getBoundConnection(host, portVal,
+                altConn = CMS.getBoundConnection("LdapUserCertPublisher", host, portVal,
                         version,
                         sslSocket, mgr_dn, mgr_pwd);
                 conn = altConn;
diff --git a/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java b/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
index ce9e3bf49d95379a3416e728adaca0557f8cdfc8..ee88865e6a92b649b6065a1104ee63ae7cc7807b 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
@@ -1350,7 +1350,7 @@ public class ConfigurationUtils {
         boolean setupReplication = cs.getBoolean("preop.database.setupReplication", true);
 
         IConfigStore dbCfg = cs.getSubStore("internaldb");
-        ILdapConnFactory dbFactory = CMS.getLdapBoundConnFactory();
+        ILdapConnFactory dbFactory = CMS.getLdapBoundConnFactory("ConfigurationUtils");
         dbFactory.init(dbCfg);
         LDAPConnection conn = dbFactory.getConn();
 
@@ -1807,7 +1807,7 @@ public class ConfigurationUtils {
         IConfigStore cs = CMS.getConfigStore();
 
         IConfigStore dbCfg = cs.getSubStore("internaldb");
-        ILdapConnFactory dbFactory = CMS.getLdapBoundConnFactory();
+        ILdapConnFactory dbFactory = CMS.getLdapBoundConnFactory("ConfigurationUtils");
         dbFactory.init(dbCfg);
         LDAPConnection conn = dbFactory.getConn();
 
@@ -1826,7 +1826,7 @@ public class ConfigurationUtils {
         IConfigStore cs = CMS.getConfigStore();
 
         IConfigStore dbCfg = cs.getSubStore("internaldb");
-        ILdapConnFactory dbFactory = CMS.getLdapBoundConnFactory();
+        ILdapConnFactory dbFactory = CMS.getLdapBoundConnFactory("ConfigurationUtils");
         dbFactory.init(dbCfg);
         LDAPConnection conn = dbFactory.getConn();
 
@@ -1897,7 +1897,7 @@ public class ConfigurationUtils {
         ILdapConnFactory masterFactory = null;
         try {
             IConfigStore masterCfg = cs.getSubStore("preop.internaldb.master");
-            masterFactory = CMS.getLdapBoundConnFactory();
+            masterFactory = CMS.getLdapBoundConnFactory("ConfigurationUtils");
             masterFactory.init(masterCfg);
             masterConn = masterFactory.getConn();
         } catch (Exception e) {
@@ -1912,7 +1912,7 @@ public class ConfigurationUtils {
         ILdapConnFactory replicaFactory = null;
         try {
             IConfigStore replicaCfg = cs.getSubStore("internaldb");
-            replicaFactory = CMS.getLdapBoundConnFactory();
+            replicaFactory = CMS.getLdapBoundConnFactory("ConfigurationUtils");
             replicaFactory.init(replicaCfg);
             replicaConn = replicaFactory.getConn();
         } catch (Exception e) {
@@ -3616,7 +3616,7 @@ public class ConfigurationUtils {
             SAXException, ParserConfigurationException {
         IConfigStore cs = CMS.getConfigStore();
         IConfigStore dbCfg = cs.getSubStore("internaldb");
-        ILdapConnFactory dbFactory = CMS.getLdapBoundConnFactory();
+        ILdapConnFactory dbFactory = CMS.getLdapBoundConnFactory("ConfigurationUtils");
         dbFactory.init(dbCfg);
         LDAPConnection conn = dbFactory.getConn();
         LDAPEntry entry = null;
@@ -4243,7 +4243,7 @@ public class ConfigurationUtils {
         IConfigStore cs = CMS.getConfigStore();
         String userbasedn = "ou=people, " + cs.getString("internaldb.basedn");
         IConfigStore dbCfg = cs.getSubStore("internaldb");
-        ILdapConnFactory dbFactory = CMS.getLdapBoundConnFactory();
+        ILdapConnFactory dbFactory = CMS.getLdapBoundConnFactory("ConfigurationUtils");
         dbFactory.init(dbCfg);
         LDAPConnection conn = dbFactory.getConn();
 
@@ -4309,7 +4309,7 @@ public class ConfigurationUtils {
 
         // update global next range entries
         IConfigStore dbCfg = cs.getSubStore("internaldb");
-        ILdapConnFactory dbFactory = CMS.getLdapBoundConnFactory();
+        ILdapConnFactory dbFactory = CMS.getLdapBoundConnFactory("ConfigurationUtils");
         dbFactory.init(dbCfg);
         LDAPConnection conn = dbFactory.getConn();
 
diff --git a/base/server/cms/src/com/netscape/cms/servlet/csadmin/SecurityDomainProcessor.java b/base/server/cms/src/com/netscape/cms/servlet/csadmin/SecurityDomainProcessor.java
index de83d20bf51b3d4f9efbd1ecf5540158c7b8da12..08b11c605ad3feb2efb30d3b754bf4dacc19a950 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/csadmin/SecurityDomainProcessor.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/csadmin/SecurityDomainProcessor.java
@@ -154,7 +154,7 @@ public class SecurityDomainProcessor extends CAProcessor {
             String filter = "objectclass=pkiSecurityGroup";
 
             IConfigStore ldapConfig = cs.getSubStore("internaldb");
-            connFactory = CMS.getLdapBoundConnFactory();
+            connFactory = CMS.getLdapBoundConnFactory("SecurityDomainProcessor");
             connFactory.init(ldapConfig);
             conn = connFactory.getConn();
 
diff --git a/base/server/cms/src/com/netscape/cms/servlet/csadmin/UpdateDomainXML.java b/base/server/cms/src/com/netscape/cms/servlet/csadmin/UpdateDomainXML.java
index 9aa150475adeab6b25ead0ced9b29a624d847d97..1a23823b2efe3cf8144f0f1a6da9f59e84aaf67b 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/csadmin/UpdateDomainXML.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/csadmin/UpdateDomainXML.java
@@ -91,7 +91,7 @@ public class UpdateDomainXML extends CMSServlet {
 
         try {
             IConfigStore ldapConfig = cs.getSubStore("internaldb");
-            connFactory = CMS.getLdapBoundConnFactory();
+            connFactory = CMS.getLdapBoundConnFactory("UpdateDomainXML");
             connFactory.init(ldapConfig);
             conn = connFactory.getConn();
             conn.delete(dn);
@@ -125,7 +125,7 @@ public class UpdateDomainXML extends CMSServlet {
 
         try {
             IConfigStore ldapConfig = cs.getSubStore("internaldb");
-            connFactory = CMS.getLdapBoundConnFactory();
+            connFactory = CMS.getLdapBoundConnFactory("UpdateDomainXML");
             connFactory.init(ldapConfig);
             conn = connFactory.getConn();
             conn.modify(dn, mod);
@@ -160,7 +160,7 @@ public class UpdateDomainXML extends CMSServlet {
 
         try {
             IConfigStore ldapConfig = cs.getSubStore("internaldb");
-            connFactory = CMS.getLdapBoundConnFactory();
+            connFactory = CMS.getLdapBoundConnFactory("UpdateDomainXML");
             connFactory.init(ldapConfig);
             conn = connFactory.getConn();
             conn.add(entry);
diff --git a/base/server/cmscore/src/com/netscape/cmscore/apps/CMSEngine.java b/base/server/cmscore/src/com/netscape/cmscore/apps/CMSEngine.java
index 02c8ab41db38b781e8a1db05c7c26c8a98f2b9ac..fa2c8147f401d19836e52737b99be0ac1f108298 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/apps/CMSEngine.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/apps/CMSEngine.java
@@ -976,14 +976,14 @@ public class CMSEngine implements ICMSEngine {
         return new LdapAuthInfo();
     }
 
-    public ILdapConnFactory getLdapBoundConnFactory()
+    public ILdapConnFactory getLdapBoundConnFactory(String id)
             throws ELdapException {
-        return new LdapBoundConnFactory();
+        return new LdapBoundConnFactory(id);
     }
 
-    public ILdapConnFactory getLdapAnonConnFactory()
+    public ILdapConnFactory getLdapAnonConnFactory(String id)
             throws ELdapException {
-        return new LdapAnonConnFactory();
+        return new LdapAnonConnFactory(id);
     }
 
     public IRequestEncoder getHttpRequestEncoder() {
@@ -1079,7 +1079,7 @@ public class CMSEngine implements ICMSEngine {
         }
     }
 
-    public LDAPConnection getBoundConnection(String host, int port,
+    public LDAPConnection getBoundConnection(String id, String host, int port,
                int version, LDAPSSLSocketFactoryExt fac, String bindDN,
                String bindPW) throws LDAPException {
         return new LdapBoundConnection(host, port, version, fac,
@@ -1796,6 +1796,14 @@ public class CMSEngine implements ICMSEngine {
         shutdownSubsystems(mFinalSubsystems);
         shutdownSubsystems(mDynSubsystems);
         shutdownSubsystems(mStaticSubsystems);
+
+        if (mSDTimer != null) {
+            mSDTimer.cancel();
+        }
+
+        if (mSecurityDomainSessionTable != null) {
+            mSecurityDomainSessionTable.shutdown();
+        }
     }
 
     /**
diff --git a/base/server/cmscore/src/com/netscape/cmscore/authentication/PasswdUserDBAuthentication.java b/base/server/cmscore/src/com/netscape/cmscore/authentication/PasswdUserDBAuthentication.java
index 2905f3c758c1d96873347434bb12a5efd063c957..692dc49d62b85b3db03bd3f46059d4f94072223b 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/authentication/PasswdUserDBAuthentication.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/authentication/PasswdUserDBAuthentication.java
@@ -95,8 +95,8 @@ public class PasswdUserDBAuthentication implements IAuthManager, IPasswdUserDBAu
             return;
 
         mBaseDN = dbs.getBaseDN();
-        mConnFactory = new LdapBoundConnFactory(3, 20, ldapinfo, dbs.getLdapAuthInfo());
-        mAnonConnFactory = new LdapAnonConnFactory(3, 20, ldapinfo);
+        mConnFactory = new LdapBoundConnFactory("PasswdUserDBAuthentication", 3, 20, ldapinfo, dbs.getLdapAuthInfo());
+        mAnonConnFactory = new LdapAnonConnFactory("PasswdUserDBAuthentication", 3, 20, ldapinfo);
 
         log(ILogger.LL_INFO, CMS.getLogMessage("CMSCORE_AUTH_INIT_AUTH", mName));
     }
@@ -242,6 +242,7 @@ public class PasswdUserDBAuthentication implements IAuthManager, IPasswdUserDBAu
         try {
             // disconnect all outstanding connections in the factory
             if (mConnFactory != null) mConnFactory.reset();
+            if (mAnonConnFactory != null) mAnonConnFactory.reset();
         } catch (ELdapException e) {
             log(ILogger.LL_FAILURE, e.toString());
         }
diff --git a/base/server/cmscore/src/com/netscape/cmscore/cert/CrossCertPairSubsystem.java b/base/server/cmscore/src/com/netscape/cmscore/cert/CrossCertPairSubsystem.java
index b0feca8c28d3efd13c166a88b394ea5845895ad9..29ec0f54fe68e5f1a016a9d641eeaa2352759ab6 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/cert/CrossCertPairSubsystem.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/cert/CrossCertPairSubsystem.java
@@ -118,7 +118,7 @@ public class CrossCertPairSubsystem implements ICrossCertPairSubsystem {
 
             mBaseDN = ldapConfig.getString(PROP_BASEDN, null);
 
-            mLdapConnFactory = new LdapBoundConnFactory();
+            mLdapConnFactory = new LdapBoundConnFactory("CrossCertPairSubsystem");
 
             if (mLdapConnFactory != null)
                 mLdapConnFactory.init(ldapConfig);
diff --git a/base/server/cmscore/src/com/netscape/cmscore/dbs/DBSubsystem.java b/base/server/cmscore/src/com/netscape/cmscore/dbs/DBSubsystem.java
index a6133310c6a935a3de408b7106a1eba4d5e40416..2de9945f78ad8a0417217ecf34ea04f21959c152 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/dbs/DBSubsystem.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/dbs/DBSubsystem.java
@@ -636,7 +636,7 @@ public class DBSubsystem implements IDBSubsystem {
 
             // initialize LDAP connection factory
             // by default return error if server is down at startup time.
-            mLdapConnFactory = new LdapBoundConnFactory(true);
+            mLdapConnFactory = new LdapBoundConnFactory("DBSubsystem", true);
             tmpConfig = (IConfigStore) (((PropConfigStore) mConfig).clone());
 
             tmpConfig.putString(PROP_BASEDN, mBaseDN);
diff --git a/base/server/cmscore/src/com/netscape/cmscore/ldap/LdapConnModule.java b/base/server/cmscore/src/com/netscape/cmscore/ldap/LdapConnModule.java
index 859e442faa65669479a5a3a3db7c0d0aa0c11e3b..3710b8a22b2c7e5bc3db89cd5dba0bcadb01a5dd 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/ldap/LdapConnModule.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/ldap/LdapConnModule.java
@@ -92,7 +92,7 @@ public class LdapConnModule implements ILdapConnModule {
 
         CMS.debug("Creating LdapBoundConnFactory for LdapConnModule.");
         mLdapConnFactory =
-                new LdapBoundConnFactory(minConns, maxConns, (LdapConnInfo) connInfo, authInfo);
+                new LdapBoundConnFactory("LDAPConnModule", minConns, maxConns, (LdapConnInfo) connInfo, authInfo);
 
         mInited = true;
 
diff --git a/base/server/cmscore/src/com/netscape/cmscore/ldap/LdapPublishModule.java b/base/server/cmscore/src/com/netscape/cmscore/ldap/LdapPublishModule.java
index c4ff20515045f31a226ce0a6a2a8d35ef00c8c80..c7a04601d033b9e848510689da93df363974fad5 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/ldap/LdapPublishModule.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/ldap/LdapPublishModule.java
@@ -119,7 +119,7 @@ public class LdapPublishModule implements ILdapPublishModule {
         mAuthority = authority;
         mPubProcessor = p;
         mConfig = config;
-        mLdapConnFactory = new LdapBoundConnFactory();
+        mLdapConnFactory = new LdapBoundConnFactory("LdapPublishModule");
         mLdapConnFactory.init(mConfig.getSubStore("ldap"));
 
         // initMappers(config);
@@ -135,7 +135,7 @@ public class LdapPublishModule implements ILdapPublishModule {
 
         mAuthority = authority;
         mConfig = config;
-        mLdapConnFactory = new LdapBoundConnFactory();
+        mLdapConnFactory = new LdapBoundConnFactory("LdapPublishModule");
         mLdapConnFactory.init(mConfig.getSubStore("ldap"));
 
         initMappers(config);
diff --git a/base/server/cmscore/src/com/netscape/cmscore/ldapconn/LdapAnonConnFactory.java b/base/server/cmscore/src/com/netscape/cmscore/ldapconn/LdapAnonConnFactory.java
index dfc974e0bdfa6d2f03d49faa7d3d5aaa04d6bd10..20e0d65b1a8e13b847d24ab645d695a01a451497 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/ldapconn/LdapAnonConnFactory.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/ldapconn/LdapAnonConnFactory.java
@@ -35,6 +35,9 @@ import com.netscape.certsrv.logging.ILogger;
  * authentication dn and password.
  */
 public class LdapAnonConnFactory implements ILdapConnFactory {
+
+    protected String id;
+
     protected int mMinConns = 5;
     protected int mMaxConns = 1000;
     protected LdapConnInfo mConnInfo = null;
@@ -60,10 +63,14 @@ public class LdapAnonConnFactory implements ILdapConnFactory {
      * Constructor for initializing from the config store.
      * must be followed by init(IConfigStore)
      */
-    public LdapAnonConnFactory() {
+    public LdapAnonConnFactory(String id) {
+        CMS.debug("Creating LdapAnonConnFactory(" + id + ")");
+        this.id = id;
     }
 
-    public LdapAnonConnFactory(boolean defErrorIfDown) {
+    public LdapAnonConnFactory(String id, boolean defErrorIfDown) {
+        CMS.debug("Creating LdapAnonConnFactory(" + id + ")");
+        this.id = id;
         mDefErrorIfDown = defErrorIfDown;
     }
 
@@ -75,8 +82,10 @@ public class LdapAnonConnFactory implements ILdapConnFactory {
      *            the maximum number of clones of this connection one wants to allow.
      * @param serverInfo server connection info - host, port, etc.
      */
-    public LdapAnonConnFactory(int minConns, int maxConns,
+    public LdapAnonConnFactory(String id, int minConns, int maxConns,
             LdapConnInfo connInfo) throws ELdapException {
+        CMS.debug("Creating LdapAnonConnFactory(" + id + ")");
+        this.id = id;
         init(minConns, maxConns, connInfo);
     }
 
@@ -405,6 +414,7 @@ public class LdapAnonConnFactory implements ILdapConnFactory {
     // ok only if no connections outstanding.
     public synchronized void reset()
             throws ELdapException {
+        CMS.debug("Destroying LdapAnonConnFactory(" + id + ")");
         if (mNumConns == mTotal) {
             for (int i = 0; i < mNumConns; i++) {
                 try {
diff --git a/base/server/cmscore/src/com/netscape/cmscore/ldapconn/LdapBoundConnFactory.java b/base/server/cmscore/src/com/netscape/cmscore/ldapconn/LdapBoundConnFactory.java
index 5be645b56ed15ccf8fb5977169270faddce73967..2ac4085c72a3d2cda36d6f16620c155e7403dfa2 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/ldapconn/LdapBoundConnFactory.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/ldapconn/LdapBoundConnFactory.java
@@ -36,6 +36,9 @@ import com.netscape.certsrv.logging.ILogger;
  * be shared by multiple threads and cloned.
  */
 public class LdapBoundConnFactory implements ILdapBoundConnFactory {
+
+    protected String id;
+
     protected int mMinConns = 5;
     protected int mMaxConns = 1000;
     protected LdapConnInfo mConnInfo = null;
@@ -71,10 +74,14 @@ public class LdapBoundConnFactory implements ILdapBoundConnFactory {
      * Constructor for initializing from the config store.
      * must be followed by init(IConfigStore)
      */
-    public LdapBoundConnFactory() {
+    public LdapBoundConnFactory(String id) {
+        CMS.debug("Creating LdapBoundConnFactor(" + id + ")");
+        this.id = id;
     }
 
-    public LdapBoundConnFactory(boolean defErrorIfDown) {
+    public LdapBoundConnFactory(String id, boolean defErrorIfDown) {
+        CMS.debug("Creating LdapBoundConnFactor(" + id + ")");
+        this.id = id;
         mDefErrorIfDown = defErrorIfDown;
     }
 
@@ -98,8 +105,10 @@ public class LdapBoundConnFactory implements ILdapBoundConnFactory {
      *            the maximum number of clones of this connection or separate connections one wants to allow.
      * @param serverInfo server connection info - host, port, etc.
      */
-    public LdapBoundConnFactory(int minConns, int maxConns,
+    public LdapBoundConnFactory(String id, int minConns, int maxConns,
             LdapConnInfo connInfo, LdapAuthInfo authInfo) throws ELdapException {
+        CMS.debug("Creating LdapBoundConnFactory(" + id + ")");
+        this.id = id;
         init(minConns, maxConns, connInfo, authInfo);
     }
 
@@ -459,11 +468,13 @@ public class LdapBoundConnFactory implements ILdapBoundConnFactory {
      */
     public synchronized void reset()
             throws ELdapException {
+        CMS.debug("Destroying LdapBoundConnFactory(" + id + ")");
         if (mNumConns == mTotal) {
             for (int i = 0; i < mNumConns; i++) {
                 try {
                     mConns[i].disconnect();
                 } catch (LDAPException e) {
+                    e.printStackTrace();
                 }
                 mConns[i] = null;
             }
@@ -472,6 +483,7 @@ public class LdapBoundConnFactory implements ILdapBoundConnFactory {
                     log(ILogger.LL_INFO, "disconnecting masterConn");
                     mMasterConn.disconnect();
                 } catch (LDAPException e) {
+                    e.printStackTrace();
                     log(ILogger.LL_FAILURE,
                             CMS.getLogMessage("CMSCORE_LDAPCONN_CANNOT_RESET",
                                     e.toString()));
diff --git a/base/server/cmscore/src/com/netscape/cmscore/logging/LogQueue.java b/base/server/cmscore/src/com/netscape/cmscore/logging/LogQueue.java
index 32af1bf2c733f3495afc9b71b7b17d6d4bed25c0..751a4cd6369637c4ce192d9728ca77bf829e51fc 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/logging/LogQueue.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/logging/LogQueue.java
@@ -64,7 +64,8 @@ public class LogQueue implements ILogQueue {
         if (mListeners == null)
             return;
         for (int i = 0; i < mListeners.size(); i++) {
-            mListeners.elementAt(i).shutdown();
+            ILogEventListener listener = mListeners.elementAt(i);
+            listener.shutdown();
         }
     }
 
@@ -75,8 +76,9 @@ public class LogQueue implements ILogQueue {
      */
     public void addLogEventListener(ILogEventListener listener) {
         //Make sure we don't have duplicated listener
-        if (!mListeners.contains(listener))
+        if (!mListeners.contains(listener)) {
             mListeners.addElement(listener);
+        }
     }
 
     /**
@@ -104,9 +106,6 @@ public class LogQueue implements ILogQueue {
                 //                        incorrect log message.
                 // ConsoleError.send(new SystemEvent(CMS.getUserMessage("CMS_LOG_EVENT_FAILED",
                 //          event.getEventType(), e.toString())));
-
-                // Don't do this again.
-                removeLogEventListener(mListeners.elementAt(i));
             }
         }
     }
diff --git a/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java b/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java
index 83ae5078dc698b5ce374951beaff6f3b7191ac39..cc2e43dfa2e9b1a4eb3bdb53eeb3ace6cfd1d6ac 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java
@@ -77,7 +77,7 @@ public class LDAPProfileSubsystem
 
         IConfigStore cs = CMS.getConfigStore();
         IConfigStore dbCfg = cs.getSubStore("internaldb");
-        dbFactory = CMS.getLdapBoundConnFactory();
+        dbFactory = CMS.getLdapBoundConnFactory("LDAPProfileSubsystem");
         dbFactory.init(dbCfg);
 
         mConfig = config;
diff --git a/base/server/cmscore/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java b/base/server/cmscore/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java
index 2a2cf8b2c907e6cb540893efc2857b888c92f382..ad1a1b0b886a580edbe4afddcda997dba6126c66 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java
@@ -1888,6 +1888,8 @@ public class SelfTestSubsystem
 
             instance.shutdownSelfTest();
         }
+
+        mLogger.shutdown();
     }
 
     /**
diff --git a/base/server/cmscore/src/com/netscape/cmscore/session/LDAPSecurityDomainSessionTable.java b/base/server/cmscore/src/com/netscape/cmscore/session/LDAPSecurityDomainSessionTable.java
index 064ae7ecbf253b5d4c74f15342f7c17bbe7efd93..bbc9f1a7967510295ffb1f7c6cae30f88b0cf41e 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/session/LDAPSecurityDomainSessionTable.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/session/LDAPSecurityDomainSessionTable.java
@@ -50,7 +50,7 @@ public class LDAPSecurityDomainSessionTable
         m_timeToLive = timeToLive;
         IConfigStore cs = CMS.getConfigStore();
         IConfigStore internaldb = cs.getSubStore("internaldb");
-        mLdapConnFactory = CMS.getLdapBoundConnFactory();
+        mLdapConnFactory = CMS.getLdapBoundConnFactory("LDAPSecurityDomainSessionTable");
         mLdapConnFactory.init(internaldb);
     }
 
@@ -300,4 +300,12 @@ public class LDAPSecurityDomainSessionTable
 
         return ret;
     }
+
+    public void shutdown() {
+        try {
+            mLdapConnFactory.reset();
+        } catch (ELdapException e) {
+            CMS.debug(e);
+        }
+    }
 }
diff --git a/base/server/cmscore/src/com/netscape/cmscore/session/SecurityDomainSessionTable.java b/base/server/cmscore/src/com/netscape/cmscore/session/SecurityDomainSessionTable.java
index 497f42f7a5db47097eff65b4dcfa33bc079fef38..c7fe25599bd07c8d2db5b4529976e873ebe9ea5a 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/session/SecurityDomainSessionTable.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/session/SecurityDomainSessionTable.java
@@ -102,4 +102,7 @@ public class SecurityDomainSessionTable
     public int getSize() {
         return m_sessions.size();
     }
+
+    public void shutdown() {
+    }
 }
diff --git a/base/server/cmscore/src/com/netscape/cmscore/usrgrp/UGSubsystem.java b/base/server/cmscore/src/com/netscape/cmscore/usrgrp/UGSubsystem.java
index a2655bf82f32a15e775d15fa04cf057a9958886c..d1277279e5c020aa688d1dedce9230d293fe3fac 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/usrgrp/UGSubsystem.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/usrgrp/UGSubsystem.java
@@ -137,7 +137,7 @@ public final class UGSubsystem implements IUGSubsystem {
 
             mBaseDN = ldapConfig.getString(PROP_BASEDN, null);
 
-            mLdapConnFactory = new LdapBoundConnFactory();
+            mLdapConnFactory = new LdapBoundConnFactory("UGSubsystem");
             mLdapConnFactory.init(ldapConfig);
         } catch (EBaseException e) {
             if (CMS.isPreOpMode())
diff --git a/base/server/cmscore/src/com/netscape/cmscore/util/Debug.java b/base/server/cmscore/src/com/netscape/cmscore/util/Debug.java
index 0365734674e7211739bc9c3db1115b1d9859887c..83c0e1b06826422741e143810e701d6b78b41492 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/util/Debug.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/util/Debug.java
@@ -20,11 +20,12 @@ package com.netscape.cmscore.util;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
 import java.io.PrintStream;
-import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Hashtable;
 import java.util.StringTokenizer;
 
+import org.apache.commons.lang.time.FastDateFormat;
+
 import com.netscape.certsrv.base.IConfigStore;
 import com.netscape.certsrv.base.ISubsystem;
 import com.netscape.cmsutil.util.Utils;
@@ -35,21 +36,9 @@ public class Debug
     private static Debug mInstance = new Debug();
     private static boolean mShowCaller = false;
 
-    /* This dateformatter is used to put the date on each
-       debug line. But the DateFormatter is not thread safe,
-       so I create a thread-local DateFormatter for each thread
-     */
+    // FastDateFormat is a thread-safe replacement for SimpleDateFormat
     private static String DATE_PATTERN = "dd/MMM/yyyy:HH:mm:ss";
-    private static ThreadLocal<SimpleDateFormat> mFormatObject = new ThreadLocal<SimpleDateFormat>() {
-        protected synchronized SimpleDateFormat initialValue() {
-            return new SimpleDateFormat(DATE_PATTERN);
-        }
-    };
-
-    /* the dateformatter should be accessed with this function */
-    private static SimpleDateFormat getDateFormatter() {
-        return mFormatObject.get();
-    }
+    private static FastDateFormat df = FastDateFormat.getInstance(DATE_PATTERN);
 
     public static final boolean ON = false;
     public static final int OBNOXIOUS = 1;
@@ -146,9 +135,8 @@ public class Debug
     private static void outputTraceMessage(String t) {
         if (!TRACE_ON)
             return;
-        SimpleDateFormat d = getDateFormatter();
-        if (mOut != null && d != null) {
-            mOut.println("[" + d.format(new Date()) + "][" + Thread.currentThread().getName() + "]: " + t);
+        if (mOut != null) {
+            mOut.println("[" + df.format(new Date()) + "][" + Thread.currentThread().getName() + "]: " + t);
             mOut.flush();
         }
     }
diff --git a/base/server/test/com/netscape/cmscore/app/CMSEngineDefaultStub.java b/base/server/test/com/netscape/cmscore/app/CMSEngineDefaultStub.java
index 0b7518d81c516b2073cc54ae69a9b9fb0262c669..404832c0db799681c15039b62082da84cc0c9756 100644
--- a/base/server/test/com/netscape/cmscore/app/CMSEngineDefaultStub.java
+++ b/base/server/test/com/netscape/cmscore/app/CMSEngineDefaultStub.java
@@ -343,16 +343,16 @@ public class CMSEngineDefaultStub implements ICMSEngine {
         return null;
     }
 
-    public ILdapConnFactory getLdapBoundConnFactory() throws ELdapException {
+    public ILdapConnFactory getLdapBoundConnFactory(String id) throws ELdapException {
         return null;
     }
 
-    public LDAPConnection getBoundConnection(String host, int port, int version, LDAPSSLSocketFactoryExt fac,
+    public LDAPConnection getBoundConnection(String id, String host, int port, int version, LDAPSSLSocketFactoryExt fac,
             String bindDN, String bindPW) throws LDAPException {
         return null;
     }
 
-    public ILdapConnFactory getLdapAnonConnFactory() throws ELdapException {
+    public ILdapConnFactory getLdapAnonConnFactory(String id) throws ELdapException {
         return null;
     }
 
-- 
1.9.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]