From 0c7c5e8e706d6323d1edf609977068b2d278446e Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 18 Oct 2019 12:58:28 +0200 Subject: [PATCH] Register action MXBean only during start 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 --- .../remote/rpc/registry/ActionRegistry.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/ActionRegistry.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/ActionRegistry.java index b90bad26f5..9669739148 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/ActionRegistry.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/ActionRegistry.java @@ -37,14 +37,13 @@ import org.opendaylight.mdsal.dom.api.DOMActionInstance; */ public class ActionRegistry extends BucketStoreActor { 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 { 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 -- 2.36.6