/** * Release the {@link StatefulConnection connection}. Closes connection {@link StatefulConnection#close()} by default. * Implementations may choose whether they override this method and return the connection to a pool. * * @param connection must not be {@literal null}. */ default void release(StatefulConnection<?, ?> connection) { LettuceFutureUtils.join(releaseAsync(connection)); }
/** * Close connection (blocking call). */ void close() { if (state.compareAndSet(State.INITIAL, CLOSING) || state.compareAndSet(State.CONNECTION_REQUESTED, CLOSING)) { StatefulConnection<ByteBuffer, ByteBuffer> connection = this.connection; this.connection = null; if (connection != null) { LettuceFutureUtils.join(connectionProvider.releaseAsync(connection)); } state.set(State.CLOSED); } }