Call onClose listener in a finally block
@@ -411,10 +411,13 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
@Override
public synchronized void close() throws IOException {
if (closed.compareAndSet(false, true)) {
+ try {
closeChannels(Arrays.stream(channels).filter(Objects::nonNull).collect(Collectors.toList()));
+ } finally {
onClose.accept(this);
}
}
+ }
@Override
public DiscoveryNode getNode() {
