我准备用grizzly做一个高并发的TCP程序,我使用的是grizzly-nio-framework-1.9.9.jar的包!服务端的代码如下:
final Controller controller = new Controller();
final ReadFilter readFilter = new ReadFilter();
final LogFilter logFilter = new LogFilter();
controller.setProtocolChainInstanceHandler(new DefaultProtocolChainInstanceHandler() {
public ProtocolChain poll() {
ProtocolChain protocolChain = (ProtocolChain)protocolChains
.poll();
if (protocolChain == null) {
protocolChain = new DefaultProtocolChain();
protocolChain.addFilter(readFilter);
protocolChain.addFilter(logFilter);
}
return protocolChain;
}
});
controller.start();
此服务端启动后我用TCP工具模拟客户端连接没有问题(没有发送数据),当往此通道中发送数据时就会报错,报错信息如下:
java.lang.NullPointerException
at com.sun.grizzly.filter.ReadFilter.execute(ReadFilter.java:124)
at com.sun.grizzly.filter.ReadFilter.execute(ReadFilter.java:100)
也就是ReadFilter类中的这一段代码:
if (byteBuffer == null) {
byteBuffer = ((WorkerThread)Thread.currentThread()).getByteBuffer();
}
if (!byteBuffer.hasRemaining()){
throw new IllegalStateException("ByteBuffer is full: " + byteBuffer);
}
"if (!byteBuffer.hasRemaining())" 错误指向的是这句话,也就是说byteBuffer此时为null
以上服务端的代码我都是按照grizzly的API文档上面写的,就是搞不清楚到底是怎么回事?小弟刚开始研究grizzly,希望JE的各位大虾们帮助解决一下!谢谢先!
分享到:
相关推荐
jar包,官方版本,自测可用
dasein-cloud-nimbula.zip,nimbula的dasin云实现。nimbula不再是dasin云的受支持平台,因为它不再是受支持的软件产品。Dasin Cloud 2013.02是Nimbula的最后一个版本。
atmosphere.zip,https://github.com/atmosphere/atmosphere/issues/1186
Albero.zip,银行用各种标准来决定客户是否会得到贷款。保险人使用特定的信息来确定哪种保险产品最适合其客户。
HBaseHUT.zip,todohbase高更新吞吐量
2014年10月24日最新Grizzly 2.3.17 API文档CHM版
亲测过的Ubuntu13.04安装Grizzly版本的OpenStack
Grizzly介绍,英文版,可以了解下。
Dubbo的核心jar包,grizzly-core-2.1.4.jar 下载,源码版本为2.5.4开发版
NULL 博文链接:https://nuhajia.iteye.com/blog/656705
grizzly 是Glassfish 前端web引擎的底层实现,类似于apache mina, 但据说要比mina性能高出很多,具有研究意义
Dubbo的核心jar包, grizzly-framework-2.1.4.jar下载,源码版本为2.5.4开发版
osgi-kernel.zip,这是一个简单的osgi运行时,能够使用maven存储库
jmxutils.zip,导出jmx mbean使导出jmx mbean变得容易
riak_pb.zip,用于与riakriak通信的协议缓冲区协议缓冲区消息
java运行依赖jar包
memcached-chart-report.zip,memcached图表报表
play-velocity-plugin.zip,Play2框架的Play Velocity插件Invelocity插件
lift-jquery-module.zip,lift-jquery-module U 2.5a jquery电梯模块
jar包,官方版本,自测可用