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(); } } }