From e2b240799c2943b7e478948d03f4f4e0e62d6ca1 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Sat, 29 Dec 2012 18:07:02 +0100 Subject: [PATCH] [#857] Check if the SelectionKey is valid before access readyOps() --- .../main/java/io/netty/channel/socket/nio/NioEventLoop.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/transport/src/main/java/io/netty/channel/socket/nio/NioEventLoop.java b/transport/src/main/java/io/netty/channel/socket/nio/NioEventLoop.java index 5bcf96792b..2021a8da49 100644 --- a/transport/src/main/java/io/netty/channel/socket/nio/NioEventLoop.java +++ b/transport/src/main/java/io/netty/channel/socket/nio/NioEventLoop.java @@ -383,6 +383,12 @@ public final class NioEventLoop extends SingleThreadEventLoop { private static void processSelectedKey(SelectionKey k, AbstractNioChannel ch) { final NioUnsafe unsafe = ch.unsafe(); + if (!k.isValid()) { + // close the channel if the key is not valid anymore + unsafe.close(unsafe.voidFuture()); + return; + } + int readyOps = -1; try { readyOps = k.readyOps();