修复DelimiterBasedFrameDecoder中保留分隔符产生的空报文,修改exceptionCaught日志输出

master
剑器近 2020-12-23 18:54:42 +08:00
parent 6fa7ee97ef
commit 077823f76d
2 changed files with 6 additions and 2 deletions

View File

@ -90,7 +90,7 @@ public class TCPServerHandler extends ChannelInboundHandlerAdapter {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable e) {
Session session = ctx.channel().attr(Session.KEY).get();
log.warn("<<<<<异常断开连接" + session, e);
log.warn("<<<<<消息处理异常" + session, e);
}
@Override

View File

@ -84,7 +84,11 @@ public class DelimiterBasedFrameDecoder extends ByteToMessageDecoder {
}
buffer.skipBytes(minDelimLength);
} else {
frame = buffer.readRetainedSlice(minFrameLength + minDelimLength);
if (minFrameLength != 0) {
frame = buffer.readRetainedSlice(minFrameLength + minDelimLength);
} else {
buffer.skipBytes(minDelimLength);
}
}
return frame;