@Nullable private PooledChannel acquireNowExact(PoolKey key, SessionProtocol protocol) { final Deque<PooledChannel> queue = getPool(protocol, key); if (queue == null) { return null; } // Find the most recently released channel while cleaning up the unhealthy channels. for (int i = queue.size(); i > 0; i--) { final PooledChannel pooledChannel = queue.peekLast(); if (!isHealthy(pooledChannel)) { queue.removeLast(); continue; } final HttpSession session = HttpSession.get(pooledChannel.get()); if (session.unfinishedResponses() >= session.maxUnfinishedResponses()) { // The channel is full of streams so we cannot create a new one. // Move the channel to the beginning of the queue so it has low priority. queue.removeLast(); queue.addFirst(pooledChannel); continue; } if (!protocol.isMultiplex()) { queue.removeLast(); } return pooledChannel; } return null; }
if (protocol.isMultiplex()) { final Http2PooledChannel pooledChannel = new Http2PooledChannel(channel, protocol); addToPool(protocol, key, pooledChannel);
if (cause == null) { final SessionProtocol actualProtocol = pch.protocol(); if (actualProtocol.isMultiplex()) { promise.complete(pch); } else {
if (!sessionProtocol.isMultiplex()) {