From: Robert Varga Date: Sun, 26 Jan 2014 09:27:24 +0000 (+0100) Subject: Resolve the service reference before intantiating proxy for it X-Git-Tag: jenkins-controller-bulk-release-prepare-only-2-10~1 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=cfed514afc0e32689c1c0e5a3ef0986a86dcbfc8 Resolve the service reference before intantiating proxy for it The original code assumed that if it has a ServiceReference, that service does not disappear. Now it resolves it before deciding whether to use a proxy. Change-Id: I4dfdf886ab1f6fca7cdd523cf3e112af6d9b1411 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java index cef37db684..51efa9e2e5 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java @@ -80,7 +80,12 @@ public final class RuntimeMappingModule extends if(serviceRef == null) { return null; } - return new RuntimeGeneratedMappingServiceProxy(getBundleContext(),serviceRef); + + BindingIndependentMappingService delegate = bundleContext.getService(serviceRef); + if (delegate == null) { + return null; + } + return new RuntimeGeneratedMappingServiceProxy(getBundleContext(),serviceRef,delegate); } private BundleContext getBundleContext() { @@ -101,10 +106,11 @@ public final class RuntimeMappingModule extends private BundleContext bundleContext; public RuntimeGeneratedMappingServiceProxy(BundleContext bundleContext, - ServiceReference serviceRef) { - this.bundleContext = bundleContext; - this.reference = serviceRef; - this.delegate = bundleContext.getService(serviceRef); + ServiceReference serviceRef, + BindingIndependentMappingService delegate) { + this.bundleContext = Preconditions.checkNotNull(bundleContext); + this.reference = Preconditions.checkNotNull(serviceRef); + this.delegate = Preconditions.checkNotNull(delegate); } public CodecRegistry getCodecRegistry() {