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
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<DatagramSessionChannel> channels = new ArrayList<DatagramSessionChannel>(datagramChannels.values());
for (DatagramSessionChannel datagramSessionChannel : channels) {
if (datagramSessionChannel.isActive()) {
datagramSessionChannel.close();
for (DatagramSessionChannel channel : channels) {
if (channel.isActive() &&
!channel.eventLoop().isShutdown()) {
channel.close();
}
}
}