Supress exception logging if the exception was expected. See #396

This commit is contained in:
norman 2012-07-03 12:01:52 +02:00
parent c3770a0fba
commit e58d657421

View File

@ -25,6 +25,7 @@ import io.netty.logging.InternalLoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.nio.channels.AsynchronousChannelGroup; import java.nio.channels.AsynchronousChannelGroup;
import java.nio.channels.AsynchronousCloseException;
import java.nio.channels.AsynchronousServerSocketChannel; import java.nio.channels.AsynchronousServerSocketChannel;
import java.nio.channels.AsynchronousSocketChannel; import java.nio.channels.AsynchronousSocketChannel;
import java.nio.channels.CompletionHandler; import java.nio.channels.CompletionHandler;
@ -123,12 +124,17 @@ public class AioServerSocketChannel extends AbstractAioChannel implements Server
// create the socket add it to the buffer and fire the event // create the socket add it to the buffer and fire the event
channel.pipeline().inboundMessageBuffer().add(new AioSocketChannel(channel, null, ch)); channel.pipeline().inboundMessageBuffer().add(new AioSocketChannel(channel, null, ch));
channel.pipeline().fireInboundBufferUpdated(); channel.pipeline().fireInboundBufferUpdated();
} }
public void failed(Throwable t, AioServerSocketChannel channel) { public void failed(Throwable t, AioServerSocketChannel channel) {
// 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); logger.warn("Failed to create a new channel from an accepted socket.", t);
} }
} }
}
@Override @Override
public AioServerSocketChannelConfig config() { public AioServerSocketChannelConfig config() {