io.netty.util.IllegalReferenceCountException: refCnt: 0

永远燃烧的凤凰 2017-08-31 01:56:27
求助,在使用netty5.0的时候遇到的这个问题
io.netty.util.IllegalReferenceCountException: refCnt: 0

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
super.channelRead(ctx, msg);
try{
ByteBuf buf = (ByteBuf) msg; //这个地方报错的
byte[] buff = new byte[buf.readableBytes()];
buf.readBytes(buff);
。。。。

W/System.err: io.netty.util.IllegalReferenceCountException: refCnt: 0
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.buffer.AbstractByteBuf.ensureAccessible(AbstractByteBuf.java:1150)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1133)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.buffer.AbstractByteBuf.readBytes(AbstractByteBuf.java:648)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.buffer.AbstractByteBuf.readBytes(AbstractByteBuf.java:656)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at com.sisisan.data.service.NettyService$SocketChannelHandler.channelRead(NettyService.java:157)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:84)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:153)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.PausableChannelEventExecutor.invokeChannelRead(PausableChannelEventExecutor.java:86)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:389)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:254)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:84)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:153)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.PausableChannelEventExecutor.invokeChannelRead(PausableChannelEventExecutor.java:86)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:389)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:243)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:84)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:153)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.PausableChannelEventExecutor.invokeChannelRead(PausableChannelEventExecutor.java:86)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:389)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:956)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:127)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:514)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:471)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:385)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:351)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.util.internal.chmv8.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1412)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.util.internal.chmv8.ForkJoinTask.doExec(ForkJoinTask.java:280)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.util.internal.chmv8.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:877)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.util.internal.chmv8.ForkJoinPool.scan(ForkJoinPool.java:1706)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.util.internal.chmv8.ForkJoinPool.runWorker(ForkJoinPool.java:1661)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/System.err: at io.netty.util.internal.chmv8.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:126)
08-31 01:53:59.209 2598-3256/com.sisisam.batmessage W/DefaultChannelPipeline: 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.
...全文
630 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
pilnyun335857183 2017-08-31
  • 打赏
  • 举报
回复
你是不是在前面的ChannelHandler里面手动调用了msg的release方法了

50,528

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧