From a8b9e27c92682dd59135622df15005d6ab0b8c09 Mon Sep 17 00:00:00 2001 From: norman Date: Wed, 25 Apr 2012 09:24:51 +0200 Subject: [PATCH] NioDatagramWorker.ChannelRegistionTask should handle ClosedChannelException gracefully. See #281 and #277 --- .../io/netty/channel/socket/nio/NioDatagramWorker.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/transport/src/main/java/io/netty/channel/socket/nio/NioDatagramWorker.java b/transport/src/main/java/io/netty/channel/socket/nio/NioDatagramWorker.java index 712b21fa99..ad84e771a6 100644 --- a/transport/src/main/java/io/netty/channel/socket/nio/NioDatagramWorker.java +++ b/transport/src/main/java/io/netty/channel/socket/nio/NioDatagramWorker.java @@ -29,6 +29,7 @@ import io.netty.channel.MessageEvent; import io.netty.channel.ReceiveBufferSizePredictor; import io.netty.channel.socket.nio.SendBufferPool.SendBuffer; +import java.io.IOException; import java.net.SocketAddress; import java.nio.ByteBuffer; import java.nio.channels.AsynchronousCloseException; @@ -154,13 +155,15 @@ public class NioDatagramWorker extends AbstractNioWorker { if (future != null) { future.setSuccess(); } - } catch (final ClosedChannelException e) { + } catch (final IOException e) { if (future != null) { future.setFailure(e); } close(channel, succeededFuture(channel)); - throw new ChannelException( - "Failed to register a socket to the selector.", e); + if (!(e instanceof ClosedChannelException)) { + throw new ChannelException( + "Failed to register a socket to the selector.", e); + } } }