Fix NPE while accessing DomTxChain when bgp/app peer singleton service is restarted
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / config / BgpPeer.java
index 4dd599dfad4d2b2a78c0db5ee6acbbb8d45286c1..425023b96ccb4bf5efcc9917547f1c2cd2a3467f 100644 (file)
@@ -154,6 +154,9 @@ public class BgpPeer implements PeerBean, BGPPeerStateConsumer {
 
     @Override
     public void close() {
+        if (this.bgpPeerSingletonService != null) {
+            this.bgpPeerSingletonService = null;
+        }
         if (this.serviceRegistration != null) {
             this.serviceRegistration.unregister();
             this.serviceRegistration = null;
@@ -170,9 +173,7 @@ public class BgpPeer implements PeerBean, BGPPeerStateConsumer {
     @Override
     public synchronized FluentFuture<? extends CommitInfo> closeServiceInstance() {
         if (this.bgpPeerSingletonService != null) {
-            final FluentFuture<? extends CommitInfo> fut = this.bgpPeerSingletonService.closeServiceInstance();
-            this.bgpPeerSingletonService = null;
-            return fut;
+            return this.bgpPeerSingletonService.closeServiceInstance();
         }
         return CommitInfo.emptyFluentFuture();
     }