Potential fix for NPE during SocketChannel.register(..)

This commit is contained in:
Trustin Lee 2008-11-06 10:55:56 +00:00
parent b15fe51e95
commit 486218ab28

View File

@ -89,11 +89,14 @@ class NioWorker implements Runnable {
boolean firstChannel = started.compareAndSet(false, true);
Selector selector;
if (firstChannel) {
selectorGuard.writeLock().lock();
try {
this.selector = selector = Selector.open();
} catch (IOException e) {
throw new ChannelException(
"Failed to create a selector.", e);
} finally {
selectorGuard.writeLock().unlock();
}
} else {
selector = this.selector;