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 / AbstractPeer.java
index 561490ae54d4739e1ec29477dbffa1eb42381e50..b85ec93456d58b812dc617667f178da3c4f29d37 100644 (file)
@@ -105,7 +105,7 @@ abstract class AbstractPeer extends BGPPeerStateImpl implements BGPRouteEntryImp
         this.clusterId = clusterId;
         this.localAs = localAs;
         this.rib = rib;
-        this.domChain = this.rib.createPeerDOMChain(this);
+        createDomChain();
     }
 
     AbstractPeer(
@@ -503,6 +503,13 @@ abstract class AbstractPeer extends BGPPeerStateImpl implements BGPRouteEntryImp
         }
     }
 
+    final synchronized void createDomChain() {
+        if (this.domChain == null) {
+            LOG.info("Creating DOM peer chain {}", getPeerId());
+            this.domChain = this.rib.createPeerDOMChain(this);
+        }
+    }
+
     final synchronized void closeDomChain() {
         if (this.domChain != null) {
             LOG.info("Closing DOM peer chain {}", getPeerId());