Bug-2418 PCEP session statistics RuntimeBean was not closed properly 17/13117/2
authorMilos Fabian <milfabia@cisco.com>
Tue, 25 Nov 2014 13:14:38 +0000 (14:14 +0100)
committerMilos Fabian <milfabia@cisco.com>
Tue, 25 Nov 2014 16:19:29 +0000 (16:19 +0000)
-RuntimeBean was not unregistered, when session was closed - causing NPE in netconf-state

Change-Id: I85cab707e4626fa0c22d02080eb90cc3be01ef7f
Signed-off-by: Milos Fabian <milfabia@cisco.com>
pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractTopologySessionListener.java

index 36d86dcd4078083f79df2b1ab08f718bc3ed8f80..8ab6a4da2d44ff0ec8969e5a314a6795a12bcf95 100644 (file)
@@ -183,6 +183,7 @@ public abstract class AbstractTopologySessionListener<S, L> implements PCEPSessi
         this.serverSessionManager.releaseNodeState(this.nodeState, session);
         this.nodeState = null;
         this.session = null;
+        unregister();
 
         // Clear all requests we know about
         for (final Entry<S, PCEPRequest> e : this.requests.entrySet()) {
@@ -245,14 +246,19 @@ public abstract class AbstractTopologySessionListener<S, L> implements PCEPSessi
 
     @Override
     public void close() {
-        if (this.registration != null) {
-            this.registration.close();
-        }
+        unregister();
         if (this.session != null) {
             this.session.close(TerminationReason.Unknown);
         }
     }
 
+    private synchronized void unregister() {
+        if (this.registration != null) {
+            this.registration.close();
+            this.registration = null;
+        }
+    }
+
     protected final synchronized PCEPRequest removeRequest(final S id) {
         final PCEPRequest ret = this.requests.remove(id);
         if (ret != null) {