Ignore incoming messages in State.FAILED 70/102770/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 18 Oct 2022 23:45:41 +0000 (01:45 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 20 Oct 2022 09:01:20 +0000 (11:01 +0200)
Once we transition to FAILED state, we should not process any other
messages, as we just waiting for close() to complete.

JIRA: NETCONF-905
Change-Id: Id7d7f657e50bb7c7ad25c1445fa0b69e1e57cdb9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 06c94657833f0ed7110a40af31af20f869cca19d)

netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java

index 54fd4146ec1fb4264f5afa613eea03e27eae47fc..0dfe5a67030446d1aa0df67a297e6cc6400f252f 100644 (file)
@@ -130,9 +130,13 @@ public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionP
         }
     }
 
-    protected final synchronized boolean ifNegotiatedAlready() {
+    protected final boolean ifNegotiatedAlready() {
         // Indicates whether negotiation already started
-        return this.state != State.IDLE;
+        return state() != State.IDLE;
+    }
+
+    private synchronized State state() {
+        return state;
     }
 
     private static @Nullable SslHandler getSslHandler(final Channel channel) {
@@ -377,6 +381,11 @@ public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionP
     @Override
     @SuppressWarnings("checkstyle:illegalCatch")
     public final void channelRead(final ChannelHandlerContext ctx, final Object msg) {
+        if (state() == State.FAILED) {
+            // We have already failed -- do not process any more messages
+            return;
+        }
+
         LOG.debug("Negotiation read invoked on channel {}", channel);
         try {
             handleMessage((NetconfHelloMessage) msg);