Fix resource leaks when exceptions are
encountered during ConfigManagerActivator.start().
Change-Id: Ic12c756aa5a768add0bc62e71eed94e5b2fa5fea
Signed-off-by: Gary Wu <Gary.Wu1@huawei.com>
try {
configRegistryJMXRegistrator.registerToJMXNoNotifications(configRegistry);
} catch (InstanceAlreadyExistsException e) {
+ configRegistryJMXRegistrator.close();
throw new IllegalStateException("Config Registry was already registered to JMX", e);
}
try {
configRegistryJMXRegistrator.registerToJMX(notifyingConfigRegistry);
} catch (InstanceAlreadyExistsException e) {
+ configRegistryJMXRegistrator.close();
+ configRegistryJMXRegistratorWithNotifications.close();
throw new IllegalStateException("Config Registry was already registered to JMX", e);
}