Fix resource leaks in exception handling
[controller.git] / 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);
             }