Fix NPE in AbstractNioWorker / Uncomment setUseClientMode()

This commit is contained in:
Trustin Lee 2012-03-01 14:27:32 -08:00
parent 4c67a24860
commit 9e8f8ac08c
2 changed files with 8 additions and 6 deletions

View File

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

View File

@ -60,8 +60,7 @@ abstract class AbstractNioWorker implements Worker {
/**
* Executor used to execute {@link Runnable}s such as
* {@link ChannelRegistionTask}.
* Executor used to execute {@link Runnable}s such as registration task.
*/
private final Executor executor;
@ -100,7 +99,7 @@ abstract class AbstractNioWorker implements Worker {
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);
@ -288,7 +287,10 @@ abstract class AbstractNioWorker implements Worker {
if (added) {
// wake up the selector to speed things
selector.wakeup();
Selector selector = this.selector;
if (selector != null) {
selector.wakeup();
}
} else {
channelRunnable.setFailure(new RejectedExecutionException("Unable to queue task " + task));
}
@ -767,7 +769,7 @@ abstract class AbstractNioWorker implements Worker {
* was something to be read. The channel would previously have registered its interest
* 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);