We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NettyServerHandler类的channelRead0最后会对msg进行引用释放,这是不正确的。如下打印一下方法返回值可见是false。跟进方法源码会发现因为类型都不对,会直接返回false。
@Override protected void channelRead0(ChannelHandlerContext ctx, RpcRequest msg) throws Exception { try { if(msg.getHeartBeat()) { logger.info("接收到客户端心跳包..."); return; } logger.info("服务器接收到请求: {}", msg); Object result = requestHandler.handle(msg); if (ctx.channel().isActive() && ctx.channel().isWritable()) { ctx.writeAndFlush(RpcResponse.success(result, msg.getRequestId())); } else { logger.error("通道不可写"); } } finally { boolean isok = ReferenceCountUtil.release(msg); logger.info(String.valueOf(isok)); } }
正确的做法应该是在上一个入站handler即最后使用btyebuf的地方进行释放
The text was updated successfully, but these errors were encountered:
补充:查看上一个入站handler继承的replaying解码器发现自动释放了bytebuf,所以正确的改法应该是去掉这句释放代码即可。
Sorry, something went wrong.
你好,我是初学者,SimpleChannelInboundHandler 这个类本来就会自动释放的吧?原文中finally代码块最后是将引用计数释放了,应该不会有什么问题吧?没有恶意,只是想学习一下!😁
SimpleChannelInboundHandler
No branches or pull requests
NettyServerHandler类的channelRead0最后会对msg进行引用释放,这是不正确的。如下打印一下方法返回值可见是false。跟进方法源码会发现因为类型都不对,会直接返回false。
正确的做法应该是在上一个入站handler即最后使用btyebuf的地方进行释放
The text was updated successfully, but these errors were encountered: