From e58d657421a6ca9e6ebd7d34f9d6cce7345b7ab3 Mon Sep 17 00:00:00 2001 From: norman Date: Tue, 3 Jul 2012 12:01:52 +0200 Subject: [PATCH] Supress exception logging if the exception was expected. See #396 --- .../netty/channel/socket/aio/AioServerSocketChannel.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/transport/src/main/java/io/netty/channel/socket/aio/AioServerSocketChannel.java b/transport/src/main/java/io/netty/channel/socket/aio/AioServerSocketChannel.java index 9aee5a1ae7..1f63c92387 100755 --- a/transport/src/main/java/io/netty/channel/socket/aio/AioServerSocketChannel.java +++ b/transport/src/main/java/io/netty/channel/socket/aio/AioServerSocketChannel.java @@ -25,6 +25,7 @@ import io.netty.logging.InternalLoggerFactory; import java.io.IOException; import java.net.SocketAddress; import java.nio.channels.AsynchronousChannelGroup; +import java.nio.channels.AsynchronousCloseException; import java.nio.channels.AsynchronousServerSocketChannel; import java.nio.channels.AsynchronousSocketChannel; import java.nio.channels.CompletionHandler; @@ -123,10 +124,15 @@ public class AioServerSocketChannel extends AbstractAioChannel implements Server // create the socket add it to the buffer and fire the event channel.pipeline().inboundMessageBuffer().add(new AioSocketChannel(channel, null, ch)); channel.pipeline().fireInboundBufferUpdated(); + } public void failed(Throwable t, AioServerSocketChannel channel) { - logger.warn("Failed to create a new channel from an accepted socket.", t); + // check if the exception was thrown because the channel was closed before + // log something + if (channel.isOpen() && !(t instanceof AsynchronousCloseException)) { + logger.warn("Failed to create a new channel from an accepted socket.", t); + } } }