我正在使用netty和redis(jedis客户端),并且在每个请求中redisdb调用的查询方法,当我使用这个命令在Apache基准测试中测试它时
ab -c 10 -n 10 本地主机:2080
发生以下错误。
Mar 10, 2014 3:29:48 PM io.netty.channel.DefaultChannelPipeline$TailHandler exceptionCaught
WARNING: An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.lang.NullPointerException
at redis.clients.jedis.Protocol.sendCommand(Protocol.java:39)
at redis.clients.jedis.Protocol.sendCommand(Protocol.java:33)
at redis.clients.jedis.Connection.sendCommand(Connection.java:80)
at redis.clients.jedis.BinaryClient.append(BinaryClient.java:200)
at redis.clients.jedis.Client.append(Client.java:125)
at redis.clients.jedis.Jedis.append(Jedis.java:616)
at com.kdgames.server.asyncdatabase.redisdb.query(redisdb.java:14)
at ServerInboundHandler.channelRead0(ServerInboundHandler.java:41)
at ServerInboundHandler.channelRead0(ServerInboundHandler.java:1)
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:103)
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:340)
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:326)
at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:340)
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:326)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:340)
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:326)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:155)
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:340)
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:326)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:116)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:494)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:461)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:378)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:350)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
at java.lang.Thread.run(Unknown Source)
这是代码
public class redisdb {
Jedis jedis;
public redisdb() {
jedis = new Jedis("192.168.56.101", 6179);
}
public void query() {
jedis.append("foo", "bar");
}
}