private void closeIfIdle() {
    NettyUtils.warnIfNotInEventLoop(parentChannel.eventLoop());

    // Don't close if we have child channels.
    if (!streamChannels.isEmpty()) {
      return;
    }

    // Don't close if there have been any reserves attempted since the idle connection time.
    long nonVolatileLastReserveAttemptTimeMillis = lastReserveAttemptTimeMillis;
    if (nonVolatileLastReserveAttemptTimeMillis > System.currentTimeMillis() - allowedIdleTimeInMs) {
      return;
    }

    // Cut off new streams from being acquired from this connection by setting the number of available channels to 0.
    // This write may fail if a reservation has happened since we checked the lastReserveAttemptTime.
    if (!numOfAvailableStreams.compareAndSet(maxConcurrentStreams, 0)) {
      return;
    }

    // If we've been closed, no need to shut down.
    if (state != RecordState.OPEN) {
      return;
    }

    log.debug("Connection {} has been idle for {}ms and will be shut down.", parentChannel,
        System.currentTimeMillis() - nonVolatileLastReserveAttemptTimeMillis);

    // Mark ourselves as closed
    state = RecordState.CLOSED;

    // Start the shutdown process by closing the connection (which should be noticed by the connection pool)
    parentChannel.close();
  }
Delivers the exception to all registered child channels, and prohibits new streams being created on this connection.
ambry-network/src/main/java/com/github/ambry/network/http2/MultiplexedChannelRecord.java