Prepare connection pool.

We now prepare the pool when the connection factory is started respective the pool has been instantiated.

Closes #3072
This commit is contained in:
Asmir Mustafic
2024-12-12 22:32:09 +01:00
committed by Mark Paluch
parent 5cc0842b2f
commit 1d6788e3ba
2 changed files with 33 additions and 2 deletions

View File

@@ -55,6 +55,7 @@ import org.springframework.util.Assert;
*
* @author Mark Paluch
* @author Christoph Strobl
* @author Asmir Mustafic
* @since 2.0
* @see #getConnection(Class)
*/
@@ -90,8 +91,18 @@ class LettucePoolingConnectionProvider implements LettuceConnectionProvider, Red
public <T extends StatefulConnection<?, ?>> T getConnection(Class<T> connectionType) {
GenericObjectPool<StatefulConnection<?, ?>> pool = pools.computeIfAbsent(connectionType, poolType -> {
return ConnectionPoolSupport.createGenericObjectPool(() -> connectionProvider.getConnection(connectionType),
poolConfig, false);
GenericObjectPool<StatefulConnection<?, ?>> newPool = ConnectionPoolSupport
.createGenericObjectPool(() -> connectionProvider.getConnection(connectionType), poolConfig, false);
try {
newPool.preparePool();
} catch (Exception ex) {
throw new PoolException("Could not prepare the pool", ex);
}
return newPool;
});
try {