public boolean release()

in zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/PerServerConnectionPool.java [351:392]


    public boolean release(PooledConnection conn) {
        if (conn == null) {
            return false;
        }
        if (conn.isInPool()) {
            return false;
        }

        if (draining) {
            LOG.debug(
                    "[{}] closing released connection during drain",
                    conn.getChannel().id());
            conn.getChannel().close();
            return false;
        }

        // Get the eventloop for this channel.
        EventLoop eventLoop = conn.getChannel().eventLoop();
        Deque<PooledConnection> connections = getPoolForEventLoop(eventLoop);

        CurrentPassport passport = CurrentPassport.fromChannel(conn.getChannel());

        // Discard conn if already at least above waterline in the pool already for this server.
        if (isOverPerServerWaterline(connections.size())) {
            closeAboveHighWaterMarkCounter.increment();
            conn.close();
            conn.setInPool(false);
            return false;
        }
        // Attempt to return connection to the pool.
        else if (connections.offer(conn)) {
            conn.setInPool(true);
            connsInPool.incrementAndGet();
            passport.add(PassportState.ORIGIN_CH_POOL_RETURNED);
            return true;
        } else {
            // If the pool is full, then close the conn and discard.
            conn.close();
            conn.setInPool(false);
            return false;
        }
    }