File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -457,10 +457,17 @@ private Connection getRecycledConnection() throws SQLException {
457457
458458 PooledConnection pconn = wrapper .pooledConnection ;
459459
460- // Skip all validation for very recently recycled connections (< 5 seconds)
460+ // Check if this is a warm-up connection that was never opened
461+ boolean isWarmupConnection =
462+ (wrapper .lastUsedTime == wrapper .createdTime && wrapper .connection .getConnection () == null );
463+
464+ // Check if the connection was recently recycled (< 5 seconds)
465+ boolean connectionIsStale = (System .currentTimeMillis () - wrapper .lastUsedTime ) > 5000 ;
466+
467+ // Skip validation for very recently recycled connections (< 5 seconds)
461468 // This dramatically improves performance for high-frequency connection reuse scenarios
462- boolean validateConnection = ( System . currentTimeMillis () - wrapper . lastUsedTime ) > 5000 ;
463- if ( validateConnection ) {
469+ if (! isWarmupConnection && connectionIsStale ) {
470+
464471 // Standard validation path for older connections
465472 boolean needsValidation = wrapper .isExpired (connectionMaxAgeMs ) ||
466473 wrapper .isIdle (connectionIdleTimeoutMs ) ||
You can’t perform that action at this time.
0 commit comments