修复参数为ByteBuf造成的ClassCastException

master
剑器近 2021-05-25 14:13:43 +08:00
parent 831970e042
commit e0c9e1abf2
1 changed files with 4 additions and 1 deletions

View File

@ -31,7 +31,10 @@ public class MessageEncoderWrapper extends ChannelOutboundHandlerAdapter {
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) { public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
ByteBuf buf = null; ByteBuf buf = null;
try { try {
buf = encoder.encode(msg); if (msg instanceof ByteBuf)
buf = (ByteBuf) msg;
else
buf = encoder.encode(msg);
if (log.isInfoEnabled()) if (log.isInfoEnabled())
log.info("<<<<<原始报文[ip={}],hex={}", ctx.channel().remoteAddress(), ByteBufUtil.hexDump(buf)); log.info("<<<<<原始报文[ip={}],hex={}", ctx.channel().remoteAddress(), ByteBufUtil.hexDump(buf));