summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi Sukma Dewata <edewata@redhat.com>2012-08-16 00:39:48 -0500
committerEndi Sukma Dewata <edewata@redhat.com>2012-08-28 14:58:43 -0500
commit4549370d8e38d91ca2d89404c6f62f7e6358f328 (patch)
tree56071b2de47bfadd1451889ee87b64c8ea028fd7
parent358fdea85e8bcb482c40a9dc2c7fa72db03974cd (diff)
downloadpki-4549370d8e38d91ca2d89404c6f62f7e6358f328.tar.gz
pki-4549370d8e38d91ca2d89404c6f62f7e6358f328.tar.xz
pki-4549370d8e38d91ca2d89404c6f62f7e6358f328.zip
Fixed exceptions during shutdown.
The shutdown() methods in several classes have been fixed to allow more graceful shutdown and clean restart. There are two types of object attributes that need to be handled differently. Attributes that are initialized by the constructor should not be nulled during shutdown because they won't be reinitialized during restart. If they require a cleanup (e.g. emptying collections, closing LDAP connections) it's not necessary to check for null before calling the cleanup method because they're never null. For attributes that are initialized during init(), it may not be necessary to do a cleanup or null the attribute since they might still be used by other threads and they will be reinitialized during restart so the old objects will be garbage collected. If they do need a cleanup they should be checked for null because they might still be null due to init() failure or initialization conditionals. If the attributes are initialized conditionally, the logic has been modified to ensure the attributes are either initialized or set to null. Ticket #247
-rw-r--r--base/ca/src/com/netscape/ca/CertificateAuthority.java23
-rw-r--r--base/common/src/com/netscape/cms/authentication/DirBasedAuthentication.java1
-rw-r--r--base/common/src/com/netscape/cms/authorization/DirAclAuthz.java3
-rw-r--r--base/common/src/com/netscape/cmscore/authentication/AuthSubsystem.java3
-rw-r--r--base/common/src/com/netscape/cmscore/authentication/PasswdUserDBAuthentication.java3
-rw-r--r--base/common/src/com/netscape/cmscore/authorization/AuthzSubsystem.java7
-rw-r--r--base/common/src/com/netscape/cmscore/cert/CrossCertPairSubsystem.java3
-rw-r--r--base/common/src/com/netscape/cmscore/dbs/DBRegistry.java4
-rw-r--r--base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java1
-rw-r--r--base/common/src/com/netscape/cmscore/ldap/PublisherProcessor.java10
-rw-r--r--base/common/src/com/netscape/cmscore/logging/LogQueue.java1
-rw-r--r--base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java4
-rw-r--r--base/common/src/com/netscape/cmscore/registry/PluginRegistry.java1
-rw-r--r--base/common/src/com/netscape/cmscore/usrgrp/UGSubsystem.java1
-rw-r--r--base/kra/src/com/netscape/kra/KeyRecoveryAuthority.java13
15 files changed, 34 insertions, 44 deletions
diff --git a/base/ca/src/com/netscape/ca/CertificateAuthority.java b/base/ca/src/com/netscape/ca/CertificateAuthority.java
index f66192cf5..f8f3d7a9b 100644
--- a/base/ca/src/com/netscape/ca/CertificateAuthority.java
+++ b/base/ca/src/com/netscape/ca/CertificateAuthority.java
@@ -527,20 +527,19 @@ public class CertificateAuthority implements ICertificateAuthority, ICertAuthori
CRLIssuingPoint point = (CRLIssuingPoint) enums.nextElement();
point.shutdown();
}
+ mCRLIssuePoints.clear();
if (mMasterCRLIssuePoint != null) {
mMasterCRLIssuePoint.shutdown();
}
- mSigningUnit = null;
- mOCSPSigningUnit = null;
- mCRLSigningUnit = null;
if (mCertRepot != null) {
mCertRepot.shutdown();
- mCertRepot = null;
}
- mCRLRepot = null;
- mPublisherProcessor.shutdown();
+
+ if (mPublisherProcessor != null) {
+ mPublisherProcessor.shutdown();
+ }
}
/**
@@ -1695,12 +1694,12 @@ public class CertificateAuthority implements ICertificateAuthority, ICertAuthori
}
// a Master/full crl must exist.
+ CRLIssuingPoint masterCRLIssuePoint = null;
while (issuePointIdEnum.hasMoreElements()) {
String issuePointId = issuePointIdEnum.nextElement();
- CMS.debug(
- "initializing crl issue point " + issuePointId);
+ CMS.debug("initializing crl issue point " + issuePointId);
IConfigStore issuePointConfig = null;
String issuePointClassName = null;
Class<CRLIssuingPoint> issuePointClass = null;
@@ -1713,9 +1712,11 @@ public class CertificateAuthority implements ICertificateAuthority, ICertAuthori
issuePoint = issuePointClass.newInstance();
issuePoint.init(this, issuePointId, issuePointConfig);
mCRLIssuePoints.put(issuePointId, issuePoint);
- if (mMasterCRLIssuePoint == null &&
+
+ if (masterCRLIssuePoint == null &&
issuePointId.equals(PROP_MASTER_CRL))
- mMasterCRLIssuePoint = issuePoint;
+ masterCRLIssuePoint = issuePoint;
+
} catch (ClassNotFoundException e) {
throw new ECAException(
CMS.getUserMessage("CMS_CA_CRL_ISSUING_POINT_INIT_FAILED",
@@ -1731,6 +1732,8 @@ public class CertificateAuthority implements ICertificateAuthority, ICertAuthori
}
}
+ mMasterCRLIssuePoint = masterCRLIssuePoint;
+
/*
if (mMasterCRLIssuePoint == null) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_CA_CA_NO_FULL_CRL", PROP_MASTER_CRL));
diff --git a/base/common/src/com/netscape/cms/authentication/DirBasedAuthentication.java b/base/common/src/com/netscape/cms/authentication/DirBasedAuthentication.java
index f52904718..f2d09df9e 100644
--- a/base/common/src/com/netscape/cms/authentication/DirBasedAuthentication.java
+++ b/base/common/src/com/netscape/cms/authentication/DirBasedAuthentication.java
@@ -435,7 +435,6 @@ public abstract class DirBasedAuthentication
try {
if (mConnFactory != null) {
mConnFactory.reset();
- mConnFactory = null;
}
} catch (ELdapException e) {
// ignore
diff --git a/base/common/src/com/netscape/cms/authorization/DirAclAuthz.java b/base/common/src/com/netscape/cms/authorization/DirAclAuthz.java
index bf4ca7f5a..133fe759e 100644
--- a/base/common/src/com/netscape/cms/authorization/DirAclAuthz.java
+++ b/base/common/src/com/netscape/cms/authorization/DirAclAuthz.java
@@ -343,8 +343,7 @@ public class DirAclAuthz extends AAclAuthz
}
try {
- mLdapConnFactory.reset();
- mLdapConnFactory = null;
+ if (mLdapConnFactory != null) mLdapConnFactory.reset();
} catch (ELdapException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("AUTHZ_EVALUATOR_LDAP_ERROR", e.toString()));
}
diff --git a/base/common/src/com/netscape/cmscore/authentication/AuthSubsystem.java b/base/common/src/com/netscape/cmscore/authentication/AuthSubsystem.java
index c5b09a7d7..549ce01f9 100644
--- a/base/common/src/com/netscape/cmscore/authentication/AuthSubsystem.java
+++ b/base/common/src/com/netscape/cmscore/authentication/AuthSubsystem.java
@@ -466,11 +466,8 @@ public class AuthSubsystem implements IAuthSubsystem {
mgr.shutdown();
}
-
mAuthMgrPlugins.clear();
- mAuthMgrPlugins = null;
mAuthMgrInsts.clear();
- mAuthMgrInsts = null;
}
public Hashtable<String, AuthMgrPlugin> getPlugins() {
diff --git a/base/common/src/com/netscape/cmscore/authentication/PasswdUserDBAuthentication.java b/base/common/src/com/netscape/cmscore/authentication/PasswdUserDBAuthentication.java
index fa8696c1d..449a196d4 100644
--- a/base/common/src/com/netscape/cmscore/authentication/PasswdUserDBAuthentication.java
+++ b/base/common/src/com/netscape/cmscore/authentication/PasswdUserDBAuthentication.java
@@ -246,8 +246,7 @@ public class PasswdUserDBAuthentication implements IAuthManager {
public void shutdown() {
try {
// disconnect all outstanding connections in the factory
- mConnFactory.reset();
- mConnFactory = null;
+ if (mConnFactory != null) mConnFactory.reset();
} catch (ELdapException e) {
log(ILogger.LL_FAILURE, e.toString());
}
diff --git a/base/common/src/com/netscape/cmscore/authorization/AuthzSubsystem.java b/base/common/src/com/netscape/cmscore/authorization/AuthzSubsystem.java
index 2c092f91c..a6019730a 100644
--- a/base/common/src/com/netscape/cmscore/authorization/AuthzSubsystem.java
+++ b/base/common/src/com/netscape/cmscore/authorization/AuthzSubsystem.java
@@ -414,9 +414,8 @@ public class AuthzSubsystem implements IAuthzSubsystem {
* <P>
*/
public void shutdown() {
- for (Enumeration<String> e = mAuthzMgrInsts.keys(); e.hasMoreElements();) {
-
- IAuthzManager mgr = get(e.nextElement());
+ for (AuthzManagerProxy proxy : mAuthzMgrInsts.values()) {
+ IAuthzManager mgr = proxy.getAuthzManager();
//String infoMsg =
// "Shutting down authz manager instance " + mgr.getName();
@@ -426,8 +425,6 @@ public class AuthzSubsystem implements IAuthzSubsystem {
}
mAuthzMgrPlugins.clear();
mAuthzMgrInsts.clear();
- mAuthzMgrPlugins = null;
- mAuthzMgrInsts = null;
}
public Hashtable<String, AuthzMgrPlugin> getPlugins() {
diff --git a/base/common/src/com/netscape/cmscore/cert/CrossCertPairSubsystem.java b/base/common/src/com/netscape/cmscore/cert/CrossCertPairSubsystem.java
index 4db850d2e..b0feca8c2 100644
--- a/base/common/src/com/netscape/cmscore/cert/CrossCertPairSubsystem.java
+++ b/base/common/src/com/netscape/cmscore/cert/CrossCertPairSubsystem.java
@@ -480,8 +480,6 @@ public class CrossCertPairSubsystem implements ICrossCertPairSubsystem {
* Stops this system.
*/
public synchronized void shutdown() {
- mCa = null;
- mPublisherProcessor = null;
if (mLdapConnFactory != null) {
try {
mLdapConnFactory.reset();
@@ -489,7 +487,6 @@ public class CrossCertPairSubsystem implements ICrossCertPairSubsystem {
CMS.debug("CrossCertPairSubsystem shutdown exception: " + e.toString());
}
}
- mLdapConnFactory = null;
}
/*
diff --git a/base/common/src/com/netscape/cmscore/dbs/DBRegistry.java b/base/common/src/com/netscape/cmscore/dbs/DBRegistry.java
index 2b6a63a62..653850e02 100644
--- a/base/common/src/com/netscape/cmscore/dbs/DBRegistry.java
+++ b/base/common/src/com/netscape/cmscore/dbs/DBRegistry.java
@@ -114,12 +114,8 @@ public class DBRegistry implements IDBRegistry, ISubsystem {
*/
public void shutdown() {
mOCclassNames.clear();
- mOCclassNames = null;
mOCldapNames.clear();
- mOCldapNames = null;
mAttrufNames.clear();
- mAttrufNames = null;
- mConverter = null;
}
/**
diff --git a/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java b/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java
index c0bb627c2..0824cc9a7 100644
--- a/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java
+++ b/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java
@@ -833,7 +833,6 @@ public class DBSubsystem implements IDBSubsystem {
try {
if (mLdapConnFactory != null) {
mLdapConnFactory.reset();
- mLdapConnFactory = null;
}
} catch (ELdapException e) {
diff --git a/base/common/src/com/netscape/cmscore/ldap/PublisherProcessor.java b/base/common/src/com/netscape/cmscore/ldap/PublisherProcessor.java
index 50ed7c3c2..5df29c10c 100644
--- a/base/common/src/com/netscape/cmscore/ldap/PublisherProcessor.java
+++ b/base/common/src/com/netscape/cmscore/ldap/PublisherProcessor.java
@@ -408,10 +408,11 @@ public class PublisherProcessor implements
CMS.debug("No LdapPublishing enabled");
}
+ LdapRequestListener listener = null;
if (mConfig.getBoolean(PROP_ENABLE, false)) {
- mLdapRequestListener = new LdapRequestListener();
- mLdapRequestListener.init(this, mLdapConfig);
- mAuthority.registerRequestListener(mLdapRequestListener);
+ listener = new LdapRequestListener();
+ listener.init(this, mLdapConfig);
+ mAuthority.registerRequestListener(listener);
IConfigStore queueConfig = mConfig.getSubStore(PROP_QUEUE_PUBLISH_SUBSTORE);
if (queueConfig != null) {
boolean isPublishingQueueEnabled = queueConfig.getBoolean("enable", false);
@@ -431,6 +432,7 @@ public class PublisherProcessor implements
savePublishingStatus);
}
}
+ mLdapRequestListener = listener;
}
public void shutdown() {
@@ -439,7 +441,7 @@ public class PublisherProcessor implements
if (mLdapConnModule != null) {
mLdapConnModule.getLdapConnFactory().reset();
}
- if (mLdapRequestListener != null) {
+ if (mAuthority != null && mLdapRequestListener != null) {
//mLdapRequestListener.shutdown();
mAuthority.removeRequestListener(mLdapRequestListener);
}
diff --git a/base/common/src/com/netscape/cmscore/logging/LogQueue.java b/base/common/src/com/netscape/cmscore/logging/LogQueue.java
index 2a63fe478..32af1bf2c 100644
--- a/base/common/src/com/netscape/cmscore/logging/LogQueue.java
+++ b/base/common/src/com/netscape/cmscore/logging/LogQueue.java
@@ -66,7 +66,6 @@ public class LogQueue implements ILogQueue {
for (int i = 0; i < mListeners.size(); i++) {
mListeners.elementAt(i).shutdown();
}
- mListeners = null;
}
/**
diff --git a/base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java b/base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java
index 1ec3c009a..27e72352e 100644
--- a/base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java
+++ b/base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java
@@ -216,11 +216,9 @@ public class ProfileSubsystem implements IProfileSubsystem {
* <P>
*/
public void shutdown() {
- mProfileIds.removeAllElements();
+ mProfileIds.clear();
mProfiles.clear();
- mProfiles = null;
mProfileClassIds.clear();
- mProfileClassIds = null;
}
/**
diff --git a/base/common/src/com/netscape/cmscore/registry/PluginRegistry.java b/base/common/src/com/netscape/cmscore/registry/PluginRegistry.java
index 1c0146222..4e3593411 100644
--- a/base/common/src/com/netscape/cmscore/registry/PluginRegistry.java
+++ b/base/common/src/com/netscape/cmscore/registry/PluginRegistry.java
@@ -246,7 +246,6 @@ public class PluginRegistry implements IPluginRegistry {
*/
public void shutdown() {
mTypes.clear();
- mTypes = null;
}
/**
diff --git a/base/common/src/com/netscape/cmscore/usrgrp/UGSubsystem.java b/base/common/src/com/netscape/cmscore/usrgrp/UGSubsystem.java
index 259173078..1a29dcf0c 100644
--- a/base/common/src/com/netscape/cmscore/usrgrp/UGSubsystem.java
+++ b/base/common/src/com/netscape/cmscore/usrgrp/UGSubsystem.java
@@ -152,7 +152,6 @@ public final class UGSubsystem implements IUGSubsystem {
try {
if (mLdapConnFactory != null) {
mLdapConnFactory.reset();
- mLdapConnFactory = null;
}
} catch (ELdapException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_USRGRP_LDAP_SHUT", e.toString()));
diff --git a/base/kra/src/com/netscape/kra/KeyRecoveryAuthority.java b/base/kra/src/com/netscape/kra/KeyRecoveryAuthority.java
index 4ba69ef9c..54cf2a0c6 100644
--- a/base/kra/src/com/netscape/kra/KeyRecoveryAuthority.java
+++ b/base/kra/src/com/netscape/kra/KeyRecoveryAuthority.java
@@ -456,14 +456,21 @@ public class KeyRecoveryAuthority implements IAuthority, IKeyService, IKeyRecove
if (!mInitialized)
return;
- mTransportKeyUnit.shutdown();
- mStorageKeyUnit.shutdown();
+ if (mTransportKeyUnit != null) {
+ mTransportKeyUnit.shutdown();
+ }
+
+ if (mStorageKeyUnit != null) {
+ mStorageKeyUnit.shutdown();
+ }
+
if (mKeyDB != null) {
mKeyDB.shutdown();
- mKeyDB = null;
}
+
getLogger().log(ILogger.EV_SYSTEM, ILogger.S_KRA,
ILogger.LL_INFO, mName.toString() + " is stopped");
+
mInitialized = false;
}