From 7a739663d766c8ee83fb17e0e4199a3945ad674f Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 6 Aug 2019 19:48:05 +0200 Subject: [PATCH 1/1] Disable updates when we are stopping We should not be propagating bundle updates when we know we are stopping. This patch marks that knowledge in the tracker. JIRA: MDSAL-466 Change-Id: Ie4e8b96907a8909150b4080000888d1d10ce8e54 Signed-off-by: Robert Varga --- .../dom/codec/osgi/impl/Activator.java | 11 ++------- .../osgi/impl/ModuleInfoBundleTracker.java | 24 +++++++++++++------ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/Activator.java b/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/Activator.java index 0c6ed145fd..a44117f09b 100644 --- a/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/Activator.java +++ b/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/Activator.java @@ -8,14 +8,10 @@ package org.opendaylight.mdsal.binding.dom.codec.osgi.impl; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import org.opendaylight.mdsal.binding.dom.codec.osgi.BindingRuntimeContextService; import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy; import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; -import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; -import org.osgi.framework.Bundle; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; @@ -24,7 +20,7 @@ import org.osgi.util.tracker.BundleTracker; public final class Activator implements BundleActivator { private final List> registrations = new ArrayList<>(2); - private BundleTracker>> moduleInfoResolvedBundleTracker = null; + private BundleTracker moduleInfoResolvedBundleTracker = null; private SimpleBindingRuntimeContextService service = null; @Override @@ -37,11 +33,8 @@ public final class Activator implements BundleActivator { final OsgiModuleInfoRegistry registry = new OsgiModuleInfoRegistry(moduleInfoBackedContext, moduleInfoBackedContext, service); - final ModuleInfoBundleTracker moduleInfoTracker = new ModuleInfoBundleTracker(registry); - moduleInfoResolvedBundleTracker = new BundleTracker<>(context, Bundle.RESOLVED | Bundle.STARTING - | Bundle.STOPPING | Bundle.ACTIVE, moduleInfoTracker); + moduleInfoResolvedBundleTracker = new ModuleInfoBundleTracker(context, registry); moduleInfoResolvedBundleTracker.open(); - moduleInfoTracker.finishStart(); service.open(); registrations.add(context.registerService(BindingRuntimeContextService.class, service, null)); diff --git a/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/ModuleInfoBundleTracker.java b/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/ModuleInfoBundleTracker.java index aeecbbbb92..0d9df8e4d3 100644 --- a/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/ModuleInfoBundleTracker.java +++ b/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/ModuleInfoBundleTracker.java @@ -23,15 +23,16 @@ import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.YangModelBindingProvider; import org.opendaylight.yangtools.yang.binding.YangModuleInfo; import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; import org.osgi.framework.BundleEvent; -import org.osgi.util.tracker.BundleTrackerCustomizer; +import org.osgi.util.tracker.BundleTracker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Tracks bundles and attempts to retrieve YangModuleInfo, which is then fed into ModuleInfoRegistry. */ -final class ModuleInfoBundleTracker implements BundleTrackerCustomizer>> { +final class ModuleInfoBundleTracker extends BundleTracker>> { private static final Logger LOG = LoggerFactory.getLogger(ModuleInfoBundleTracker.class); // FIXME: this should be in a place shared with maven-sal-api-gen-plugin private static final String MODULE_INFO_PROVIDER_PATH_PREFIX = "META-INF/services/"; @@ -43,17 +44,26 @@ final class ModuleInfoBundleTracker implements BundleTrackerCustomizer> addingBundle(final Bundle bundle, final BundleEvent event) { @@ -91,7 +101,7 @@ final class ModuleInfoBundleTracker implements BundleTrackerCustomizer