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 1f538e5c6dc848bb5f9ef334d8d12df0d50807c9..50ab13eb68d4fa4c2bee1cde8f1f685322c5f3e4 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);
             }