Rely on framework to unregister XPathParserFactory 06/83906/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 22 Aug 2019 12:57:38 +0000 (14:57 +0200)
committerRobert Varga <nite@hq.sk>
Thu, 22 Aug 2019 15:04:47 +0000 (15:04 +0000)
This simplifies the code a bit while also squashing two SpotBug
violations.

Change-Id: Ie3f146568510a949e3c7d332c95c59b90f17c7b0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-xpath-impl/src/main/java/org/opendaylight/yangtools/yang/xpath/impl/Activator.java

index 665631b51a2ce2b456ef896d1407d86dd3ceb423..0ab894f08b17bcc2be0e19a1539cf891f05a8302 100644 (file)
@@ -11,7 +11,6 @@ import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.xpath.api.YangXPathParserFactory;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
 
 /**
  * YANG XPath implementation activator. Publishes a {@link YangXPathParserFactory} implementation on bundle start.
@@ -19,18 +18,13 @@ import org.osgi.framework.ServiceRegistration;
  * @author Robert Varga
  */
 public final class Activator implements BundleActivator {
-    private @Nullable ServiceRegistration<YangXPathParserFactory> registration;
-
     @Override
     public void start(final @Nullable BundleContext context) throws Exception {
-        registration = context.registerService(YangXPathParserFactory.class, new AntlrXPathParserFactory(), null);
+        context.registerService(YangXPathParserFactory.class, new AntlrXPathParserFactory(), null);
     }
 
     @Override
     public void stop(final @Nullable BundleContext context) throws Exception {
-        if (registration != null) {
-            registration.unregister();
-            registration = null;
-        }
+        // No-op, framework will unregister our services
     }
 }