Synchronize BgpPeer.close() 29/98529/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 15 Nov 2021 08:46:27 +0000 (09:46 +0100)
committerRobert Varga <nite@hq.sk>
Mon, 15 Nov 2021 13:43:34 +0000 (13:43 +0000)
We may be racing with other callbacks, make sure we synchronize. Also
ensure we guard registrations properly.

Change-Id: If6b1e679b91bd2da21d82f0ac81f570c51284f10
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/BgpPeer.java

index cc397952357a52e6665af0d6eb2c0ff9e7420261..187a0385c4997df8be59da916caafae6255f0ca2 100644 (file)
@@ -167,13 +167,15 @@ public class BgpPeer implements PeerBean, BGPPeerStateProvider {
     }
 
     @Override
-    public void close() {
+    public synchronized void close() {
         if (this.bgpPeerSingletonService != null) {
-            this.stateProviderRegistration.close();
             this.bgpPeerSingletonService.closeServiceInstance();
-            this.stateProviderRegistration = null;
             this.bgpPeerSingletonService = null;
         }
+        if (this.stateProviderRegistration != null) {
+            this.stateProviderRegistration.close();
+            this.stateProviderRegistration = null;
+        }
     }
 
     @Override