Datagram session now checks if event loop is shutdown before trying to

close
This commit is contained in:
nathan 2018-04-03 15:53:01 +02:00
parent 5d2fa50de2
commit a4cf9f4834

View File

@ -124,16 +124,18 @@ class SessionManager extends ChannelInboundHandlerAdapter {
@Override @Override
public public
void channelInactive(final ChannelHandlerContext ctx) throws Exception { void channelInactive(final ChannelHandlerContext context) throws Exception {
super.channelInactive(ctx); super.channelInactive(context);
// have to close all of the "fake" DatagramChannels as well. Each one will remove itself from the channel map. // 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 // We make a copy of this b/c of concurrent modification, in the event this is closed BEFORE the child-channels are closed
ArrayList<DatagramSessionChannel> channels = new ArrayList<DatagramSessionChannel>(datagramChannels.values()); ArrayList<DatagramSessionChannel> channels = new ArrayList<DatagramSessionChannel>(datagramChannels.values());
for (DatagramSessionChannel datagramSessionChannel : channels) { for (DatagramSessionChannel channel : channels) {
if (datagramSessionChannel.isActive()) { if (channel.isActive() &&
datagramSessionChannel.close(); !channel.eventLoop().isShutdown()) {
channel.close();
} }
} }
} }