diff --git a/reactor-netty-core/src/main/java/reactor/netty/resources/PooledConnectionProvider.java b/reactor-netty-core/src/main/java/reactor/netty/resources/PooledConnectionProvider.java index 4aebd6dacb..a732ee09a2 100644 --- a/reactor-netty-core/src/main/java/reactor/netty/resources/PooledConnectionProvider.java +++ b/reactor-netty-core/src/main/java/reactor/netty/resources/PooledConnectionProvider.java @@ -55,6 +55,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.StringJoiner; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.TimeUnit; @@ -364,17 +365,31 @@ protected static void logPoolState(Channel channel, InstrumentedPool pool, String msg, @Nullable Throwable t) { - InstrumentedPool.PoolMetrics metrics = pool.metrics(); + String logMsg = msg + ", " + stringifyPoolMetrics(pool); + if (t == null) { + log.debug(format(channel, logMsg)); + return; + } + log.debug( - format(channel, "{}, now: {} active connections, {} inactive connections and {} pending acquire requests."), - msg, - metrics.acquiredSize(), - metrics.idleSize(), - metrics.pendingAcquireSize(), + format(channel, logMsg), t ); } + private static String stringifyPoolMetrics(InstrumentedPool pool) { + InstrumentedPool.PoolMetrics metrics = pool.metrics(); + return new StringJoiner(" ") + .add("now:") + .add(String.valueOf(metrics.acquiredSize())) + .add("active connections,") + .add(String.valueOf(metrics.idleSize())) + .add("inactive connections") + .add(String.valueOf(metrics.pendingAcquireSize())) + .add("pending acquire requests.") + .toString(); + } + final void scheduleInactivePoolsDisposal() { if (!inactivePoolDisposeInterval.isZero()) { Schedulers.parallel()