Register action MXBean only during start 01/85201/1 master
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 18 Oct 2019 10:58:28 +0000 (12:58 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 18 Oct 2019 10:58:28 +0000 (12:58 +0200)
We should not be registering resources until we are started, this
fixes an exception seen in Genius UT.

Change-Id: I5a95d7e2ddbc71eca23c57843eea64f0c58dfc7c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/ActionRegistry.java

index b90bad2..9669739 100644 (file)
@@ -37,14 +37,13 @@ import org.opendaylight.mdsal.dom.api.DOMActionInstance;
  */
 public class ActionRegistry extends BucketStoreActor<ActionRoutingTable> {
     private final ActorRef rpcRegistrar;
-    private final RemoteActionRegistryMXBeanImpl mxBean;
+
+    private RemoteActionRegistryMXBeanImpl mxBean;
 
     public ActionRegistry(final RemoteOpsProviderConfig config, final ActorRef rpcInvoker,
                           final ActorRef rpcRegistrar) {
         super(config, config.getRpcRegistryPersistenceId(), new ActionRoutingTable(rpcInvoker, ImmutableSet.of()));
         this.rpcRegistrar = requireNonNull(rpcRegistrar);
-        this.mxBean = new RemoteActionRegistryMXBeanImpl(new BucketStoreAccess(self(), getContext().dispatcher(),
-                config.getAskDuration()), config.getAskDuration());
     }
 
     /**
@@ -60,10 +59,20 @@ public class ActionRegistry extends BucketStoreActor<ActionRoutingTable> {
         return Props.create(ActionRegistry.class, config, opsInvoker, opsRegistrar);
     }
 
+    @Override
+    public void preStart() {
+        super.preStart();
+        mxBean = new RemoteActionRegistryMXBeanImpl(new BucketStoreAccess(self(), getContext().dispatcher(),
+            getConfig().getAskDuration()), getConfig().getAskDuration());
+    }
+
     @Override
     public void postStop() throws Exception {
+        if (mxBean != null) {
+            mxBean.unregister();
+            mxBean = null;
+        }
         super.postStop();
-        this.mxBean.unregister();
     }
 
     @Override

©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.