From a4cf9f4834aab12e3b4e021de7a56dcab2ff480e Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 3 Apr 2018 15:53:01 +0200 Subject: [PATCH] Datagram session now checks if event loop is shutdown before trying to close --- src/io/netty/bootstrap/SessionManager.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/io/netty/bootstrap/SessionManager.java b/src/io/netty/bootstrap/SessionManager.java index 5196c431..08720c93 100644 --- a/src/io/netty/bootstrap/SessionManager.java +++ b/src/io/netty/bootstrap/SessionManager.java @@ -124,16 +124,18 @@ class SessionManager extends ChannelInboundHandlerAdapter { @Override public - void channelInactive(final ChannelHandlerContext ctx) throws Exception { - super.channelInactive(ctx); + void channelInactive(final ChannelHandlerContext context) throws Exception { + super.channelInactive(context); // have to close all of the "fake" DatagramChannels as well. Each one will remove itself from the channel map. // We make a copy of this b/c of concurrent modification, in the event this is closed BEFORE the child-channels are closed ArrayList channels = new ArrayList(datagramChannels.values()); - for (DatagramSessionChannel datagramSessionChannel : channels) { - if (datagramSessionChannel.isActive()) { - datagramSessionChannel.close(); + for (DatagramSessionChannel channel : channels) { + if (channel.isActive() && + !channel.eventLoop().isShutdown()) { + + channel.close(); } } }