From 4b53508710b5b450e8331889636e1a8bdd6d1d78 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 28 Dec 2023 21:57:03 +0100 Subject: [PATCH] Use constructor injection in OSGiActorSystemProvider Upgraded SpotBugs does not like us not having initialized fields, use contructor injection to side-step these warnings. Change-Id: I3eef23b3cea88c97ccd8cb8794ec0587f07ccc77 Signed-off-by: Robert Varga --- .../osgi/impl/OSGiActorSystemProvider.java | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/akka/osgi/impl/OSGiActorSystemProvider.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/akka/osgi/impl/OSGiActorSystemProvider.java index 05af18d32f..60a72b07f9 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/akka/osgi/impl/OSGiActorSystemProvider.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/akka/osgi/impl/OSGiActorSystemProvider.java @@ -8,7 +8,6 @@ package org.opendaylight.controller.cluster.akka.osgi.impl; import akka.actor.ActorSystem; -import com.typesafe.config.Config; import java.util.concurrent.TimeoutException; import org.opendaylight.controller.cluster.ActorSystemProvider; import org.opendaylight.controller.cluster.ActorSystemProviderListener; @@ -30,26 +29,12 @@ import scala.concurrent.duration.Duration; public final class OSGiActorSystemProvider implements ActorSystemProvider { private static final Logger LOG = LoggerFactory.getLogger(OSGiActorSystemProvider.class); - @Reference - AkkaConfigurationReader reader = null; - private ActorSystemProviderImpl delegate; - @Override - public ActorSystem getActorSystem() { - return delegate.getActorSystem(); - } - - @Override - public ListenerRegistration registerActorSystemProviderListener( - final ActorSystemProviderListener listener) { - return delegate.registerActorSystemProviderListener(listener); - } - @Activate - void activate(final BundleContext bundleContext) { + public OSGiActorSystemProvider(@Reference final AkkaConfigurationReader reader, final BundleContext bundleContext) { LOG.info("Actor System provider starting"); - final Config akkaConfig = AkkaConfigFactory.createAkkaConfig(reader); + final var akkaConfig = AkkaConfigFactory.createAkkaConfig(reader); delegate = new ActorSystemProviderImpl(BundleClassLoaderFactory.createClassLoader(bundleContext), QuarantinedMonitorActorPropsFactory.createProps(bundleContext, akkaConfig), akkaConfig); LOG.info("Actor System provider started"); @@ -62,5 +47,16 @@ public final class OSGiActorSystemProvider implements ActorSystemProvider { delegate = null; LOG.info("Actor System provider stopped"); } + + @Override + public ActorSystem getActorSystem() { + return delegate.getActorSystem(); + } + + @Override + public ListenerRegistration registerActorSystemProviderListener( + final ActorSystemProviderListener listener) { + return delegate.registerActorSystemProviderListener(listener); + } } -- 2.36.6