From: Robert Varga Date: Fri, 11 Oct 2019 12:32:14 +0000 (+0200) Subject: Register MXBean only during start X-Git-Tag: release/magnesium~52 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=73b088ee110766618a8728eed653b15cef896cf1;ds=sidebyside Register MXBean only during start We should not be registering resources until we are started, this fixes an exception seen in Genius UT. Change-Id: I550b586f905ec95a06cc9aaec167eb584592ba46 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistry.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistry.java index 8e0b9c51ea..2c89f14260 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistry.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistry.java @@ -42,13 +42,12 @@ import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier; */ public class RpcRegistry extends BucketStoreActor { private final ActorRef rpcRegistrar; - private final RemoteRpcRegistryMXBeanImpl mxBean; + private RemoteRpcRegistryMXBeanImpl mxBean; public RpcRegistry(final RemoteOpsProviderConfig config, final ActorRef rpcInvoker, final ActorRef rpcRegistrar) { super(config, config.getRpcRegistryPersistenceId(), new RoutingTable(rpcInvoker, ImmutableSet.of())); this.rpcRegistrar = requireNonNull(rpcRegistrar); - this.mxBean = new RemoteRpcRegistryMXBeanImpl(new BucketStoreAccess(self(), getContext().dispatcher(), - config.getAskDuration()), config.getAskDuration()); + } /** @@ -64,10 +63,20 @@ public class RpcRegistry extends BucketStoreActor { return Props.create(RpcRegistry.class, config, rpcInvoker, rpcRegistrar); } + @Override + public void preStart() { + super.preStart(); + mxBean = new RemoteRpcRegistryMXBeanImpl(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