From 4549370d8e38d91ca2d89404c6f62f7e6358f328 Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Thu, 16 Aug 2012 00:39:48 -0500 Subject: 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 --- base/kra/src/com/netscape/kra/KeyRecoveryAuthority.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'base/kra/src') 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; } -- cgit