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

This commit is contained in:
norman 2012-04-25 09:21:33 +02:00
parent 7e00f614d3
commit c6ce31db96

View File

@ -28,6 +28,7 @@ import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.ReceiveBufferSizePredictor; import org.jboss.netty.channel.ReceiveBufferSizePredictor;
import java.io.IOException;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousCloseException; import java.nio.channels.AsynchronousCloseException;
@ -200,13 +201,16 @@ public class NioDatagramWorker extends AbstractNioWorker {
if (future != null) { if (future != null) {
future.setSuccess(); future.setSuccess();
} }
} catch (final ClosedChannelException e) { } catch (final IOException e) {
if (future != null) { if (future != null) {
future.setFailure(e); future.setFailure(e);
} }
close(channel, succeededFuture(channel)); 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);
}
} }
} }
} }