最近测试netty开发的服务端应用在关闭时,出现下列异常:
-》###WARN#########nioEventLoopGroup-3-2###io.netty.util.internal.logging.Slf4JLogger.warn(Slf4JLogger.java:151)###Failed to submit an exceptionCaught() event.
java.util.concurrent.RejectedExecutionException: event executor terminated
at io.netty.util.concurrent.SingleThreadEventExecutor.reject(SingleThreadEventExecutor.java:805)
at io.netty.util.concurrent.SingleThreadEventExecutor.offerTask(SingleThreadEventExecutor.java:345)
at io.netty.util.concurrent.SingleThreadEventExecutor.addTask(SingleThreadEventExecutor.java:338)
at io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:748)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:272)
at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:261)
at io.netty.channel.ChannelHandlerAdapter.exceptionCaught(ChannelHandlerAdapter.java:79)
经查,发现是因为关闭服务端的时候,主要是因为没有主动断开客户端的连接,而客户端又有心跳线程所致。而此时work-group线程组已经关闭了。先调整为主动断开所有的客户端连接。