summaryrefslogtreecommitdiffstats
path: root/base/kra
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 /base/kra
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
Diffstat (limited to 'base/kra')
-rw-r--r--base/kra/src/com/netscape/kra/KeyRecoveryAuthority.java13
1 files changed, 10 insertions, 3 deletions
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;
}