code: private void potentiallyCloseLeakingChannel(final SocketChannel ch,
      final MemcachedNode node) {
      if (ch != null && !ch.isConnected() && !ch.isConnectionPending()) {
        try {
          ch.close();
        } catch (IOException e) {
          getLogger().error("Exception closing channel: %s", node, e);
        }
      }
    }
docs: Make sure channel connections are not leaked and properly close under
  faulty reconnect cirumstances.
  
  @param ch the channel to potentially close.
  @param node the node to which the channel should be bound to.