From: Robert Varga Date: Wed, 3 Jun 2020 12:35:18 +0000 (+0200) Subject: Fix PeopleProvider activation X-Git-Tag: v2.0.2~5 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=a38cb72c22e667a90a2abea2a12ba4039b865c6d Fix PeopleProvider activation Detected by CSIT, this was broken during MD-SAL API removal. Rework instantiation to use constructor injection and proper shutdown. Fixes the following splat: java.lang.NullPointerException: null at org.opendaylight.controller.clustering.it.provider.PeopleProvider$1.onSuccess(PeopleProvider.java:74) ~[bundleFile:?] at org.opendaylight.controller.clustering.it.provider.PeopleProvider$1.onSuccess(PeopleProvider.java:70) ~[bundleFile:?] at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1078) ~[bundleFile:?] at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:30) ~[bundleFile:?] at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1164) [bundleFile:?] at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:958) [bundleFile:?] at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:727) [bundleFile:?] at com.google.common.util.concurrent.AbstractTransformFuture$TransformFuture.setResult(AbstractTransformFuture.java:247) [bundleFile:?] at com.google.common.util.concurrent.AbstractTransformFuture.run(AbstractTransformFuture.java:163) [bundleFile:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?] at java.lang.Thread.run(Thread.java:834) [?:?] Change-Id: I08273c8112ec4d3592440975b77e4ce3467d78a2 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java index fd1acaf024..e958c86643 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java @@ -7,6 +7,8 @@ */ package org.opendaylight.controller.clustering.it.provider; +import static java.util.Objects.requireNonNull; + import com.google.common.collect.ImmutableSet; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.ListenableFuture; @@ -40,16 +42,15 @@ public class PeopleProvider implements PeopleService, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(PeopleProvider.class); private final Set> regs = new HashSet<>(); - private DataBroker dataProvider; - private RpcProviderService rpcProviderService; - private CarPurchaseService rpcImplementation; - - public void setDataProvider(final DataBroker salDataProvider) { - this.dataProvider = salDataProvider; - } + private final DataBroker dataProvider; + private final RpcProviderService rpcProviderService; + private final CarPurchaseService rpcImplementation; - public void setRpcImplementation(final CarPurchaseService rpcImplementation) { - this.rpcImplementation = rpcImplementation; + public PeopleProvider(final DataBroker dataProvider, final RpcProviderService rpcProviderService, + final CarPurchaseService rpcImplementation) { + this.dataProvider = requireNonNull(dataProvider); + this.rpcProviderService = requireNonNull(rpcProviderService); + this.rpcImplementation = requireNonNull(rpcImplementation); } @Override diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/resources/OSGI-INF/blueprint/cluster-test-app.xml b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/resources/OSGI-INF/blueprint/cluster-test-app.xml index 11bea1ab21..ef8c73bbbc 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/resources/OSGI-INF/blueprint/cluster-test-app.xml +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/resources/OSGI-INF/blueprint/cluster-test-app.xml @@ -27,13 +27,15 @@ - - - + + + + + destroy-method="close">