From 6314d686b918668f1b168996af157cb3960c0e7d Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 14 Aug 2021 14:26:57 +0200 Subject: [PATCH] Reduce NETCONF device disconnect warnings Document java.io.EOFException as the natural end-of-stream cause and handle that case with less alarm as other causes. JIRA: NETCONF-805 Change-Id: If3b07125434e2a5faec90b1cd0144dc3d9f6c818 Signed-off-by: Robert Varga --- .../netconf/api/NetconfSessionListener.java | 5 ++++- .../netconf/nettyutil/AbstractNetconfSession.java | 15 +++++++-------- .../nettyutil/AbstractNetconfSessionTest.java | 3 ++- .../listener/NetconfDeviceCommunicator.java | 7 ++++++- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfSessionListener.java b/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfSessionListener.java index 6f64fc5b73..9574c47df5 100644 --- a/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfSessionListener.java +++ b/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfSessionListener.java @@ -7,6 +7,8 @@ */ package org.opendaylight.netconf.api; +import java.io.EOFException; + // FIXME: NETCONF-554: rework this interface public interface NetconfSessionListener { /** @@ -21,7 +23,8 @@ public interface NetconfSessionListener { * session. * * @param session that went down - * @param cause Exception that was thrown as the cause of session being down + * @param cause Exception that was thrown as the cause of session being down. A common cause is + * {@link EOFException}, which indicates the remote end has shut down the communication channel. */ void onSessionDown(S session, Exception cause); diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSession.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSession.java index aab5b6d0c0..d8c0697ae5 100644 --- a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSession.java +++ b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSession.java @@ -15,7 +15,7 @@ import io.netty.channel.ChannelPromise; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.handler.codec.MessageToByteEncoder; -import java.io.IOException; +import java.io.EOFException; import org.opendaylight.netconf.api.NetconfExiSession; import org.opendaylight.netconf.api.NetconfMessage; import org.opendaylight.netconf.api.NetconfSession; @@ -31,10 +31,11 @@ import org.opendaylight.netconf.shaded.exificient.core.exceptions.UnsupportedOpt import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public abstract class AbstractNetconfSession> +public abstract class AbstractNetconfSession> extends SimpleChannelInboundHandler implements NetconfSession, NetconfExiSession { - private static final Logger LOG = LoggerFactory.getLogger(AbstractNetconfSession.class); + + private final L sessionListener; private final long sessionId; private boolean up = false; @@ -88,11 +89,9 @@ public abstract class AbstractNetconfSession