X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fblueprint%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fblueprint%2Fext%2FStaticServiceReferenceRecipe.java;h=525fc82c197762d6a735f81fa20b668dc3048188;hp=8f3ca2446ac01da4158441e5d00668d138d2c54c;hb=3859df9beca8f13f1ff2b2744ed3470a1715bec3;hpb=d8be13e36b4a5fca3155e7ab3e840ba9ab5a75b1 diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/StaticServiceReferenceRecipe.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/StaticServiceReferenceRecipe.java index 8f3ca2446a..525fc82c19 100644 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/StaticServiceReferenceRecipe.java +++ b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/StaticServiceReferenceRecipe.java @@ -7,7 +7,9 @@ */ package org.opendaylight.controller.blueprint.ext; -import com.google.common.base.Preconditions; +import static com.google.common.base.Preconditions.checkNotNull; +import static java.util.Objects.requireNonNull; + import java.util.Collections; import java.util.function.Consumer; import org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe; @@ -28,7 +30,7 @@ class StaticServiceReferenceRecipe extends AbstractServiceReferenceRecipe { private static final Logger LOG = LoggerFactory.getLogger(StaticServiceReferenceRecipe.class); private static final SatisfactionListener NOOP_LISTENER = satisfiable -> { - + // Intentional NOOP }; private volatile ServiceReference trackedServiceReference; @@ -58,7 +60,7 @@ class StaticServiceReferenceRecipe extends AbstractServiceReferenceRecipe { LOG.debug("{}: In untrack {}", getName(), reference); if (trackedServiceReference == reference) { - LOG.debug("{}: Current reference has been untracked", getName(), trackedServiceReference); + LOG.debug("{}: Current reference {} has been untracked", getName(), trackedServiceReference); } } @@ -78,6 +80,8 @@ class StaticServiceReferenceRecipe extends AbstractServiceReferenceRecipe { } @Override + // Disables "Either log or rethrow this exception" sonar warning + @SuppressWarnings("squid:S1166") protected void doStop() { LOG.debug("{}: In doStop", getName()); @@ -104,14 +108,16 @@ class StaticServiceReferenceRecipe extends AbstractServiceReferenceRecipe { return trackedService; } - Preconditions.checkNotNull(localTrackedServiceReference, "trackedServiceReference is null"); - - trackedService = getServiceSecurely(localTrackedServiceReference); + trackedService = getServiceSecurely(requireNonNull(localTrackedServiceReference, + "trackedServiceReference is null")); LOG.debug("{}: Returning service instance: {}", getName(), trackedService); - Preconditions.checkNotNull(trackedService, "getService() returned null for %s", localTrackedServiceReference); + return checkNotNull(trackedService, "getService() returned null for %s", localTrackedServiceReference); + } - return trackedService; + @Override + public boolean isStaticLifecycle() { + return true; } }