Fix a NPE in DefaultChannelPipeline.write(...)

- Also re-enabled logging handler in the echo example
This commit is contained in:
Trustin Lee 2012-06-07 17:00:21 +09:00
parent ea0c9cfe79
commit 6b819fb993
3 changed files with 8 additions and 10 deletions

View File

@ -22,6 +22,8 @@ import io.netty.channel.ChannelOption;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioEventLoop;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import java.net.InetSocketAddress;
@ -55,7 +57,7 @@ public class EchoClient {
@Override
public void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(
//new LoggingHandler(LogLevel.INFO),
new LoggingHandler(LogLevel.INFO),
new EchoClientHandler(firstMessageSize));
}
});

View File

@ -19,10 +19,11 @@ import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.socket.ServerSocketChannel;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioEventLoop;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import java.net.InetSocketAddress;
@ -46,17 +47,12 @@ public class EchoServer {
.option(ChannelOption.SO_BACKLOG, 100)
.localAddress(new InetSocketAddress(port))
.childOption(ChannelOption.TCP_NODELAY, true)
.handler(new ChannelInitializer<ServerSocketChannel>() {
@Override
public void initChannel(ServerSocketChannel ch) throws Exception {
//ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO));
}
})
.handler(new LoggingHandler(LogLevel.INFO))
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(
//new LoggingHandler(LogLevel.INFO),
new LoggingHandler(LogLevel.INFO),
new EchoServerHandler());
}
});

View File

@ -1471,7 +1471,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
msgBuf = true;
executor = ctx.executor();
break;
} else if (message instanceof ChannelBuffer) {
} if (message instanceof ChannelBuffer && ctx.hasOutboundByteBuffer()) {
executor = ctx.executor();
break;
}