Workaround for JDK NIO bug. See #203

This commit is contained in:
Norman Maurer 2012-02-28 14:19:29 +01:00
parent 2b9df060dd
commit 19358ee246

View File

@ -28,6 +28,24 @@ final class SelectorUtil {
static final int DEFAULT_IO_THREADS = Runtime.getRuntime().availableProcessors() * 2;
// Workaround for JDK NIO bug.
//
// See:
// - http://bugs.sun.com/view_bug.do?bug_id=6427854
// - https://github.com/netty/netty/issues/203
static {
String key = "sun.nio.ch.bugLevel";
try {
String buglevel = System.getProperty(key);
if (buglevel == null) {
System.setProperty(key, "");
}
} catch (SecurityException e) {
if (logger.isDebugEnabled()) {
logger.debug("Unable to get/set System Property '" + key + "'", e);
}
}
}
static void select(Selector selector) throws IOException {
try {
selector.select(500);