Provide new runtime bean registrator for recreated module 91/32291/2
authorMaros Marsalek <mmarsale@cisco.com>
Fri, 8 Jan 2016 16:32:06 +0000 (17:32 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 8 Jan 2016 20:17:56 +0000 (20:17 +0000)
After recent changes in config-manager, runtime bean registrations are not
preserved after reconfiguration of a module. This is caused because internal
jmx registrators are now properly closed. Runtime bean registrations relied
on previous, incorrect behavior.

This commit fixes the issue by recreating runtime bean registrator for each module.
However there's a possible leak if clients do not close runtime bean registrations
in their createInstance methods.

Change-Id: I37f0956effdd2a183390252615c23a90e23ebe8e
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigRegistryImpl.java

index da6b83c86e8547b555eacd68bd01f857f5ff5b37..737e2ae334fdaeab12990237f5d8024561fc1e73 100644 (file)
@@ -257,15 +257,10 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
         Map<ModuleIdentifier, RootRuntimeBeanRegistratorImpl> runtimeRegistrators = new HashMap<>();
         for (ModuleInternalTransactionalInfo entry : commitInfo.getCommitted()
                 .values()) {
-            RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator;
-            if (entry.hasOldModule() == false) {
-                runtimeBeanRegistrator = baseJMXRegistrator
-                        .createRuntimeBeanRegistrator(entry.getIdentifier());
-            } else {
-                // reuse old JMX registrator
-                runtimeBeanRegistrator = entry.getOldInternalInfo()
-                        .getRuntimeBeanRegistrator();
-            }
+            // FIXME creating new Runtime bean registrator for each new instance might cause leaks if client
+            // code doesn't close registration (and thus underlying registrator) in createInstance
+            RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator = baseJMXRegistrator
+                    .createRuntimeBeanRegistrator(entry.getIdentifier());
             // set runtime jmx registrator if required
             Module module = entry.getProxiedModule();
             if (module instanceof RuntimeBeanRegistratorAwareModule) {