异常处理优化

This commit is contained in:
aoshiguchen
2023-04-07 15:20:48 +08:00
parent 252a6ac7c1
commit 5bf21b7c2c
2 changed files with 6 additions and 1 deletions
@@ -61,7 +61,9 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<ProxyMessa
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
super.exceptionCaught(ctx, cause);
cause.printStackTrace();
if (ctx.channel().isActive()) {
ctx.channel().close();
}
}
@Override
@@ -106,6 +106,9 @@ public class ServerChannelHandler extends SimpleChannelInboundHandler<ProxyMessa
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
super.exceptionCaught(ctx, cause);
if (ctx.channel().isActive()) {
ctx.channel().close();
}
}
@Override