Bug 2697: Improvement wrong response handling, missing message 94/15194/3
authorMarian Dubai <mdubai@cisco.com>
Thu, 12 Feb 2015 11:42:54 +0000 (12:42 +0100)
committerMarian Dubai <mdubai@cisco.com>
Thu, 12 Feb 2015 16:04:17 +0000 (16:04 +0000)
Improve wrong response handling in sal-netconf-connector, omitting requests without matching message (in case message got lost etc.)

Change-Id: I1692b71d45a26e01ad7e9aa83c7129e2fcbe1c77
Signed-off-by: Marian Dubai <mdubai@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/test/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfDeviceCommunicatorTest.java

index 8553820b40095755d4ee82361d184cbf5590fc9e..c62f56ac1ebd29b2c9eabf065a3512ec24ba60b2 100644 (file)
@@ -248,6 +248,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;
             }
 
index 68fe87fb6036b0cab08cb277682416df49415f26..0ff5e2d3d50014dcaf5ddc6184e9fda4a1ecb295 100644 (file)
@@ -296,6 +296,27 @@ public class NetconfDeviceCommunicatorTest {
         return new NetconfMessage( doc );
     }
 
+    //Test scenario verifying whether missing message is handled
+    @Test
+    public void testOnMissingResponseMessage() throws Exception {
+
+        setupSession();
+
+        String messageID1 = UUID.randomUUID().toString();
+        ListenableFuture<RpcResult<NetconfMessage>> resultFuture1 = sendRequest( messageID1 );
+
+        String messageID2 = UUID.randomUUID().toString();
+        ListenableFuture<RpcResult<NetconfMessage>> resultFuture2 = sendRequest( messageID2 );
+
+        String messageID3 = UUID.randomUUID().toString();
+        ListenableFuture<RpcResult<NetconfMessage>> resultFuture3 = sendRequest( messageID3 );
+
+        //response messages 1,2 are omitted
+        communicator.onMessage( mockSession, createSuccessResponseMessage( messageID3 ) );
+
+        verifyResponseMessage( resultFuture3.get(), messageID3 );
+    }
+
     @Test
     public void testOnSuccessfulResponseMessage() throws Exception {
         setupSession();