Potention fix for NPE in NioWorker.RegisterTask.run()

This commit is contained in:
Trustin Lee 2008-11-07 17:38:02 +00:00
parent 0976673ac2
commit cd3acef9e1

View File

@ -72,7 +72,7 @@ class NioWorker implements Runnable {
private final Executor executor; private final Executor executor;
private final AtomicBoolean started = new AtomicBoolean(); private final AtomicBoolean started = new AtomicBoolean();
private volatile Thread thread; private volatile Thread thread;
private volatile Selector selector; volatile Selector selector;
private final AtomicBoolean wakenUp = new AtomicBoolean(); private final AtomicBoolean wakenUp = new AtomicBoolean();
private final ReadWriteLock selectorGuard = new ReentrantReadWriteLock(); private final ReadWriteLock selectorGuard = new ReentrantReadWriteLock();
private final Object shutdownLock = new Object(); private final Object shutdownLock = new Object();
@ -123,7 +123,7 @@ class NioWorker implements Runnable {
} }
boolean server = !(channel instanceof NioClientSocketChannel); boolean server = !(channel instanceof NioClientSocketChannel);
Runnable registerTask = new RegisterTask(selector, channel, future, server); Runnable registerTask = new RegisterTask(channel, future, server);
synchronized (shutdownLock) { synchronized (shutdownLock) {
registerTaskQueue.offer(registerTask); registerTaskQueue.offer(registerTask);
} }
@ -848,16 +848,13 @@ class NioWorker implements Runnable {
} }
private class RegisterTask implements Runnable { private class RegisterTask implements Runnable {
private final Selector selector;
private final NioSocketChannel channel; private final NioSocketChannel channel;
private final ChannelFuture future; private final ChannelFuture future;
private final boolean server; private final boolean server;
RegisterTask( RegisterTask(
Selector selector,
NioSocketChannel channel, ChannelFuture future, boolean server) { NioSocketChannel channel, ChannelFuture future, boolean server) {
this.selector = selector;
this.channel = channel; this.channel = channel;
this.future = future; this.future = future;
this.server = server; this.server = server;