From 21b7e29ea7c211bb2b889bae3a0c6c5d9f60fb01 Mon Sep 17 00:00:00 2001 From: Xiaoqin Fu <48848615+xiaoqin-fu@users.noreply.github.com> Date: Fri, 30 Aug 2019 01:37:30 -0700 Subject: [PATCH] Remove extra checks to fix #9456 (#9523) Motivation: There are some extra log level checks (logger.isWarnEnabled()). Modification: Remove log level checks (logger.isWarnEnabled()) from io.netty.channel.epoll.AbstractEpollStreamChannel, io.netty.channel.DefaultFileRegion, io.netty.channel.nio.AbstractNioChannel, io.netty.util.HashedWheelTimer, io.netty.handler.stream.ChunkedWriteHandler and io.netty.channel.udt.nio.NioUdtMessageConnectorChannel Result: Fixes #9456 --- common/src/main/java/io/netty/util/HashedWheelTimer.java | 4 +--- .../java/io/netty/handler/stream/ChunkedWriteHandler.java | 4 +--- .../io/netty/channel/epoll/AbstractEpollStreamChannel.java | 4 +--- .../netty/channel/udt/nio/NioUdtMessageConnectorChannel.java | 4 +--- .../src/main/java/io/netty/channel/DefaultFileRegion.java | 4 +--- .../main/java/io/netty/channel/nio/AbstractNioChannel.java | 4 +--- 6 files changed, 6 insertions(+), 18 deletions(-) diff --git a/common/src/main/java/io/netty/util/HashedWheelTimer.java b/common/src/main/java/io/netty/util/HashedWheelTimer.java index 899673a0bb..008fdbc0d7 100644 --- a/common/src/main/java/io/netty/util/HashedWheelTimer.java +++ b/common/src/main/java/io/netty/util/HashedWheelTimer.java @@ -270,10 +270,8 @@ public class HashedWheelTimer implements Timer { } if (duration < MILLISECOND_NANOS) { - if (logger.isWarnEnabled()) { - logger.warn("Configured tickDuration {} smaller then {}, using 1ms.", + logger.warn("Configured tickDuration {} smaller then {}, using 1ms.", tickDuration, MILLISECOND_NANOS); - } this.tickDuration = MILLISECOND_NANOS; } else { this.tickDuration = duration; diff --git a/handler/src/main/java/io/netty/handler/stream/ChunkedWriteHandler.java b/handler/src/main/java/io/netty/handler/stream/ChunkedWriteHandler.java index 1a1822b597..2e248db008 100644 --- a/handler/src/main/java/io/netty/handler/stream/ChunkedWriteHandler.java +++ b/handler/src/main/java/io/netty/handler/stream/ChunkedWriteHandler.java @@ -119,9 +119,7 @@ public class ChunkedWriteHandler extends ChannelDuplexHandler { try { doFlush(ctx); } catch (Exception e) { - if (logger.isWarnEnabled()) { - logger.warn("Unexpected exception while sending chunks.", e); - } + logger.warn("Unexpected exception while sending chunks.", e); } } diff --git a/transport-native-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java b/transport-native-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java index db4878c1ef..95e31b380f 100644 --- a/transport-native-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java +++ b/transport-native-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java @@ -701,9 +701,7 @@ public abstract class AbstractEpollStreamChannel extends AbstractEpollChannel im try { fd.close(); } catch (IOException e) { - if (logger.isWarnEnabled()) { - logger.warn("Error while closing a pipe", e); - } + logger.warn("Error while closing a pipe", e); } } } diff --git a/transport-udt/src/main/java/io/netty/channel/udt/nio/NioUdtMessageConnectorChannel.java b/transport-udt/src/main/java/io/netty/channel/udt/nio/NioUdtMessageConnectorChannel.java index ca0f295fc5..204b0b76d2 100644 --- a/transport-udt/src/main/java/io/netty/channel/udt/nio/NioUdtMessageConnectorChannel.java +++ b/transport-udt/src/main/java/io/netty/channel/udt/nio/NioUdtMessageConnectorChannel.java @@ -79,9 +79,7 @@ public class NioUdtMessageConnectorChannel extends AbstractNioMessageChannel imp try { channelUDT.close(); } catch (final Exception e2) { - if (logger.isWarnEnabled()) { - logger.warn("Failed to close channel.", e2); - } + logger.warn("Failed to close channel.", e2); } throw new ChannelException("Failed to configure channel.", e); } diff --git a/transport/src/main/java/io/netty/channel/DefaultFileRegion.java b/transport/src/main/java/io/netty/channel/DefaultFileRegion.java index 2f6bea95a1..330630ce4f 100644 --- a/transport/src/main/java/io/netty/channel/DefaultFileRegion.java +++ b/transport/src/main/java/io/netty/channel/DefaultFileRegion.java @@ -161,9 +161,7 @@ public class DefaultFileRegion extends AbstractReferenceCounted implements FileR try { file.close(); } catch (IOException e) { - if (logger.isWarnEnabled()) { - logger.warn("Failed to close a file.", e); - } + logger.warn("Failed to close a file.", e); } } diff --git a/transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java b/transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java index efefb51f0e..a1c4520344 100644 --- a/transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java +++ b/transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java @@ -86,10 +86,8 @@ public abstract class AbstractNioChannel extends AbstractChannel { try { ch.close(); } catch (IOException e2) { - if (logger.isWarnEnabled()) { - logger.warn( + logger.warn( "Failed to close a partially initialized socket.", e2); - } } throw new ChannelException("Failed to enter non-blocking mode.", e);