BUG-2739 Fix concurrent metadata cleanup for netconf-connector 43/16843/1
authorMaros Marsalek <mmarsale@cisco.com>
Thu, 19 Mar 2015 17:16:49 +0000 (18:16 +0100)
committerMaros Marsalek <mmarsale@cisco.com>
Thu, 19 Mar 2015 17:16:49 +0000 (18:16 +0100)
When deleting/closing a netconf-connector, the cleanup came from 2-3 places and
was not properly synchronized resulting in failed transaction with metadata
still present

Change-Id: I91f1c8bf3d5d24cc2cf4fdb02fb1f5cc3f8a8796
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfDeviceCommunicator.java
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalFacade.java

index ce5aa79af0f85c44dc0beaa68650597f4974213a..4f2f6ab38ea204a45b02473b55130900d9c627c3 100644 (file)
@@ -110,7 +110,7 @@ public class NetconfDeviceCommunicator implements NetconfClientSessionListener,
 
             @Override
             public void operationComplete(Future<Object> future) throws Exception {
-                if (!future.isSuccess()) {
+                if (!future.isSuccess() && !future.isCancelled()) {
                     logger.debug("{}: Connection failed", id, future.cause());
                     NetconfDeviceCommunicator.this.remoteDevice.onRemoteSessionFailed(future.cause());
                 }
@@ -197,9 +197,8 @@ public class NetconfDeviceCommunicator implements NetconfClientSessionListener,
         // Disconnect from device
         if(session != null) {
             session.close();
+            // tear down not necessary, called indirectly by above close
         }
-
-        tearDown(id + ": Netconf session closed");
     }
 
     @Override
index ad16532bad095feb56a5cec4824d2205835d793a..11f82c02bfb9b9e8e65925cd0a7d0b802737267b 100644 (file)
@@ -73,14 +73,14 @@ public final class NetconfDeviceSalFacade implements AutoCloseable, RemoteDevice
     }
 
     @Override
-    public void onDeviceFailed(final Throwable throwable) {
+    public synchronized void onDeviceFailed(final Throwable throwable) {
         salProvider.getTopologyDatastoreAdapter().setDeviceAsFailed(throwable);
         salProvider.getMountInstance().onDeviceDisconnected();
         salProvider.getMountInstance().onTopologyDeviceDisconnected();
     }
 
     @Override
-    public void close() {
+    public synchronized void close() {
         for (final AutoCloseable reg : Lists.reverse(salRegistrations)) {
             closeGracefully(reg);
         }