NioDatagramWorker.ChannelRegistionTask should handle ClosedChannelException gracefully. See #281 and #277

This commit is contained in:
norman 2012-04-25 09:24:51 +02:00
parent 476cf97b97
commit a8b9e27c92

View File

@ -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);
}
}
}