Fix NPE in AbstractNioWorker / Uncomment setUseClientMode()

This commit is contained in:
Trustin Lee 2012-03-01 14:28:17 -08:00
parent 1df328034f
commit 8871ed2228
2 changed files with 10 additions and 8 deletions

View File

@ -60,8 +60,8 @@ abstract class AbstractNioWorker implements Worker {
/** /**
* Executor used to execute {@link Runnable}s such as * Executor used to execute {@link Runnable}s such as channel registration
* {@link ChannelRegistionTask}. * task.
*/ */
private final Executor executor; private final Executor executor;
@ -100,7 +100,7 @@ abstract class AbstractNioWorker implements Worker {
private final Object startStopLock = new Object(); private final Object startStopLock = new Object();
/** /**
* Queue of {@link ChannelRegistionTask}s * Queue of channel registration tasks.
*/ */
private final Queue<Runnable> registerTaskQueue = QueueFactory.createQueue(Runnable.class); private final Queue<Runnable> registerTaskQueue = QueueFactory.createQueue(Runnable.class);
@ -286,14 +286,16 @@ abstract class AbstractNioWorker implements Worker {
if (added) { if (added) {
// wake up the selector to speed things // wake up the selector to speed things
// wake up the selector to speed things
Selector selector = this.selector;
if (selector != null) {
selector.wakeup(); selector.wakeup();
}
} else { } else {
channelRunnable.setFailure(new RejectedExecutionException("Unable to queue task " + task)); channelRunnable.setFailure(new RejectedExecutionException("Unable to queue task " + task));
} }
return channelRunnable; return channelRunnable;
} }
} }
private void processRegisterTaskQueue() throws IOException { private void processRegisterTaskQueue() throws IOException {
@ -765,7 +767,7 @@ abstract class AbstractNioWorker implements Worker {
* was something to be read. The channel would previously have registered its interest * was something to be read. The channel would previously have registered its interest
* in read operations. * in read operations.
* *
* @param key The selection key which contains the Selector registration information. * @param k The selection key which contains the Selector registration information.
*/ */
protected abstract boolean read(SelectionKey k); protected abstract boolean read(SelectionKey k);

View File

@ -44,7 +44,7 @@ public class SecureChatClientPipelineFactory implements
SSLEngine engine = SSLEngine engine =
SecureChatSslContextFactory.getClientContext().createSSLEngine(); SecureChatSslContextFactory.getClientContext().createSSLEngine();
//engine.setUseClientMode(true); engine.setUseClientMode(true);
pipeline.addLast("ssl", new SslHandler(engine)); pipeline.addLast("ssl", new SslHandler(engine));