Duplicate channel futures list before closing channels.

Resolves issue 221
This commit is contained in:
Mike Hearn 2012-07-21 23:02:07 +02:00
parent bc47fccaeb
commit c5caeaea74

View file

@ -501,10 +501,13 @@ public class PeerGroup {
synchronized (PeerGroup.this) {
running = false;
shutdownPeerDiscovery();
LinkedList<ChannelFuture> futures;
synchronized (channelFutures) {
for (ChannelFuture future : channelFutures.values()) {
future.getChannel().close();
}
// Copy the list here because the act of closing the channel modifies the channelFutures map.
futures = new LinkedList<ChannelFuture>(channelFutures.values());
}
for (ChannelFuture future : futures) {
future.getChannel().close();
}
bootstrap.releaseExternalResources();
}