Merge "BUG 2854 : Do not add empty read write transactions to the replicable journal"
[controller.git] / opendaylight / md-sal / sal-netconf-connector / src / main / java / org / opendaylight / controller / sal / connect / netconf / listener / NetconfDeviceCommunicator.java
index 8553820b40095755d4ee82361d184cbf5590fc9e..4f2f6ab38ea204a45b02473b55130900d9c627c3 100644 (file)
@@ -86,7 +86,7 @@ public class NetconfDeviceCommunicator implements NetconfClientSessionListener,
             logger.trace("{}: Session advertised capabilities: {}", id, netconfSessionPreferences);
 
             if(overrideNetconfCapabilities.isPresent()) {
-                netconfSessionPreferences = netconfSessionPreferences.replaceModuleCaps(overrideNetconfCapabilities.get());
+                netconfSessionPreferences = netconfSessionPreferences.addModuleCaps(overrideNetconfCapabilities.get());
                 logger.debug("{}: Session capabilities overridden, capabilities that will be used: {}", id, netconfSessionPreferences);
             }
 
@@ -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
@@ -248,6 +247,10 @@ public class NetconfDeviceCommunicator implements NetconfClientSessionListener,
 
                 request.future.set( RpcResultBuilder.<NetconfMessage>failed()
                         .withRpcError( NetconfMessageTransformUtil.toRpcError( e ) ).build() );
+
+                //recursively processing message to eventually find matching request
+                processMessage(message);
+
                 return;
             }