Ignore incoming messages in State.FAILED 56/102756/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 18 Oct 2022 23:45:41 +0000 (01:45 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 19 Oct 2022 00:31:42 +0000 (02:31 +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>
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java

index c72312fa79558d16110085f7e438aece60a46885..ef71afc3cdf8ee07570778223627f780d5620197 100644 (file)
@@ -134,9 +134,13 @@ public abstract class AbstractNetconfSessionNegotiator<S extends AbstractNetconf
         }
     }
 
-    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) {
@@ -373,6 +377,11 @@ public abstract class AbstractNetconfSessionNegotiator<S extends AbstractNetconf
     @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);