Fix resource leaks in exception handling 09/28709/3
authorGary Wu <Gary.Wu1@huawei.com>
Thu, 22 Oct 2015 20:01:13 +0000 (13:01 -0700)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 23 Oct 2015 18:19:45 +0000 (18:19 +0000)
Fix resource leaks when exceptions are
encountered during ConfigManagerActivator.start().

Change-Id: Ic12c756aa5a768add0bc62e71eed94e5b2fa5fea
Signed-off-by: Gary Wu <Gary.Wu1@huawei.com>
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java

index 1f538e5..50ab13e 100644 (file)
@@ -98,6 +98,7 @@ public class ConfigManagerActivator implements BundleActivator {
             try {
                 configRegistryJMXRegistrator.registerToJMXNoNotifications(configRegistry);
             } catch (InstanceAlreadyExistsException e) {
+                configRegistryJMXRegistrator.close();
                 throw new IllegalStateException("Config Registry was already registered to JMX", e);
             }
 
@@ -106,6 +107,8 @@ public class ConfigManagerActivator implements BundleActivator {
             try {
                 configRegistryJMXRegistrator.registerToJMX(notifyingConfigRegistry);
             } catch (InstanceAlreadyExistsException e) {
+                configRegistryJMXRegistrator.close();
+                configRegistryJMXRegistratorWithNotifications.close();
                 throw new IllegalStateException("Config Registry was already registered to JMX", e);
             }
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.