From c9b7f1f1b570eab9eb6b61df0e94cd4dbcc5e2ec Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Fri, 11 Oct 2013 12:07:46 +0900 Subject: [PATCH] Ensure the selector implementation can be instrumented before attempting instrumentation - Fixes #1908 --- .../src/main/java/io/netty/channel/nio/NioEventLoop.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java b/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java index d8eadf4a92..d04554a61a 100644 --- a/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java +++ b/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java @@ -137,7 +137,12 @@ public final class NioEventLoop extends SingleThreadEventLoop { Class selectorImplClass = Class.forName("sun.nio.ch.SelectorImpl", false, ClassLoader.getSystemClassLoader()); - selectorImplClass.isAssignableFrom(selector.getClass()); + + // Ensure the current selector implementation is what we can instrument. + if (!selectorImplClass.isAssignableFrom(selector.getClass())) { + return selector; + } + Field selectedKeysField = selectorImplClass.getDeclaredField("selectedKeys"); Field publicSelectedKeysField = selectorImplClass.getDeclaredField("publicSelectedKeys");