From e9af1f44a4f7bf5f36a9cf584463ea3de932eefc Mon Sep 17 00:00:00 2001 From: Thomas Vachuska Date: Mon, 6 Jul 2015 08:42:18 -0700 Subject: [PATCH] Suppressing some error messages that pollute the log on switch disconnect. Change-Id: Ia79e0efcdf8552a4be1ce6b6cb562100f077bd90 --- .../controller/impl/OFChannelHandler.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFChannelHandler.java b/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFChannelHandler.java index 2f29822cb1..56dd085b55 100644 --- a/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFChannelHandler.java +++ b/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFChannelHandler.java @@ -80,6 +80,10 @@ import org.slf4j.LoggerFactory; */ class OFChannelHandler extends IdleStateAwareChannelHandler { private static final Logger log = LoggerFactory.getLogger(OFChannelHandler.class); + + private static final String RESET_BY_PEER = "Connection reset by peer"; + private static final String BROKEN_PIPE = "Broken pipe"; + private final Controller controller; private OpenFlowSwitchDriver sw; private long thisdpid; // channelHandler cached value of connected switch id @@ -1094,11 +1098,14 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { } else if (e.getCause() instanceof ClosedChannelException) { log.debug("Channel for sw {} already closed", getSwitchInfoString()); } else if (e.getCause() instanceof IOException) { - log.error("Disconnecting switch {} due to IO Error: {}", - getSwitchInfoString(), e.getCause().getMessage()); - if (log.isDebugEnabled()) { - // still print stack trace if debug is enabled - log.debug("StackTrace for previous Exception: ", e.getCause()); + if (!e.getCause().getMessage().equals(RESET_BY_PEER) && + !e.getCause().getMessage().equals(BROKEN_PIPE)) { + log.error("Disconnecting switch {} due to IO Error: {}", + getSwitchInfoString(), e.getCause().getMessage()); + if (log.isDebugEnabled()) { + // still print stack trace if debug is enabled + log.debug("StackTrace for previous Exception: ", e.getCause()); + } } ctx.getChannel().close(); } else if (e.getCause() instanceof SwitchStateException) {