Bug 2932: NPE on bundle activation 98/18798/8
authorMarian Dubai <mdubai@cisco.com>
Wed, 22 Apr 2015 07:53:21 +0000 (09:53 +0200)
committerMarian Dubai <mdubai@cisco.com>
Mon, 27 Apr 2015 10:04:01 +0000 (12:04 +0200)
Error might occured when value containing YangStoreContext
is overwritten to null by refresh method, executed within another thread.
After fix, in case context is null, context is calculated again.

Change-Id: Icefe2a5970ec2ce0b67d5b3b386a35f781fc4156
Signed-off-by: Marian Dubai <mdubai@cisco.com>
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreService.java

index 2961662..ac3873e 100644 (file)
@@ -137,15 +137,15 @@ public class YangStoreService implements YangStoreContext {
     }
 
     public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
-        final SoftReference<YangStoreSnapshot> yangStoreSnapshotSoftReference = ref.get();
 
-        YangStoreContext ret = yangStoreSnapshotSoftReference != null ? yangStoreSnapshotSoftReference.get() : null;
-        if(ret == null) {
-            ret = getYangStoreSnapshot();
+        YangStoreContext context = ref.get().get();
+
+        if(context == null) {
+            context = getYangStoreSnapshot();
         }
 
         this.listeners.add(listener);
-        listener.onCapabilitiesAdded(NetconfOperationServiceFactoryImpl.setupCapabilities(ret));
+        listener.onCapabilitiesAdded(NetconfOperationServiceFactoryImpl.setupCapabilities(context));
 
         return new AutoCloseable() {
             @Override

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.