Skip to content

Commit 8c9af9d

Browse files
committed
Polishing.
Delegate RedisClientProvider.getClient() across connection providers. Use SimpleAsyncTaskExecutor as default in ClusterCommandExecutor to avoid ThreadPoolTaskExecutor pollution. See #2575
1 parent aadfae6 commit 8c9af9d

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import org.springframework.beans.factory.DisposableBean;
2626
import org.springframework.core.task.AsyncTaskExecutor;
27+
import org.springframework.core.task.SimpleAsyncTaskExecutor;
2728
import org.springframework.dao.DataAccessException;
2829
import org.springframework.data.redis.ClusterRedirectException;
2930
import org.springframework.data.redis.ClusterStateFailureException;
@@ -87,9 +88,7 @@ public ClusterCommandExecutor(ClusterTopologyProvider topologyProvider, ClusterN
8788

8889
{
8990
if (executor == null) {
90-
ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
91-
threadPoolTaskExecutor.initialize();
92-
this.executor = threadPoolTaskExecutor;
91+
this.executor = new SimpleAsyncTaskExecutor();
9392
}
9493
}
9594

src/main/java/org/springframework/data/redis/connection/lettuce/LettucePoolingConnectionProvider.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ class LettucePoolingConnectionProvider implements LettuceConnectionProvider, Red
9999
StatefulConnection<?, ?> connection = pool.borrowObject();
100100

101101
poolRef.put(connection, pool);
102-
103102
return connectionType.cast(connection);
104103
} catch (Exception e) {
105104
throw new PoolException("Could not get a resource from the pool", e);

src/main/java/org/springframework/data/redis/connection/lettuce/StandaloneConnectionProvider.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.springframework.data.redis.connection.lettuce;
1717

18+
import io.lettuce.core.AbstractRedisClient;
1819
import io.lettuce.core.ReadFrom;
1920
import io.lettuce.core.RedisClient;
2021
import io.lettuce.core.RedisURI;
@@ -44,7 +45,7 @@
4445
* @author Christoph Strobl
4546
* @since 2.0
4647
*/
47-
class StandaloneConnectionProvider implements LettuceConnectionProvider, TargetAware {
48+
class StandaloneConnectionProvider implements LettuceConnectionProvider, TargetAware, RedisClientProvider {
4849

4950
private final RedisClient client;
5051
private final RedisCodec<?, ?> codec;
@@ -142,6 +143,11 @@ public RedisURI get() {
142143
.failed(new UnsupportedOperationException("Connection type " + connectionType + " not supported"));
143144
}
144145

146+
@Override
147+
public AbstractRedisClient getRedisClient() {
148+
return client;
149+
}
150+
145151
private StatefulRedisConnection masterReplicaConnection(RedisURI redisUri, ReadFrom readFrom) {
146152

147153
StatefulRedisMasterReplicaConnection<?, ?> connection = MasterReplica.connect(client, codec, redisUri);

0 commit comments

Comments
 (0)