Polish "Use Redis client configuration to configure connection factories"
In particular, the Lettuce code is not using the new builder API when pooling is required. This will be fixed in a future milestone. Closes gh-9510
This commit is contained in:
parent
866fdb5d91
commit
a4688bdb86
|
|
@ -33,7 +33,6 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.data.redis.connection.RedisClusterConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||
import org.springframework.data.redis.connection.jedis.JedisClientConfiguration;
|
||||
import org.springframework.data.redis.connection.jedis.JedisClientConfiguration.JedisClientConfigurationBuilder;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnection;
|
||||
|
|
@ -55,12 +54,10 @@ class JedisConnectionConfiguration extends RedisConnectionConfiguration {
|
|||
private final List<JedisClientConfigurationBuilderCustomizer> builderCustomizers;
|
||||
|
||||
JedisConnectionConfiguration(RedisProperties properties,
|
||||
ObjectProvider<RedisStandaloneConfiguration> standaloneConfiguration,
|
||||
ObjectProvider<RedisSentinelConfiguration> sentinelConfiguration,
|
||||
ObjectProvider<RedisClusterConfiguration> clusterConfiguration,
|
||||
ObjectProvider<List<JedisClientConfigurationBuilderCustomizer>> builderCustomizers) {
|
||||
super(properties, standaloneConfiguration, sentinelConfiguration,
|
||||
clusterConfiguration);
|
||||
super(properties, sentinelConfiguration, clusterConfiguration);
|
||||
this.properties = properties;
|
||||
this.builderCustomizers = builderCustomizers
|
||||
.getIfAvailable(Collections::emptyList);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.data.redis.connection.RedisClusterConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||
import org.springframework.data.redis.connection.lettuce.DefaultLettucePool;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceClientConfigurationBuilder;
|
||||
|
|
@ -58,12 +57,10 @@ class LettuceConnectionConfiguration extends RedisConnectionConfiguration {
|
|||
private final List<LettuceClientConfigurationBuilderCustomizer> builderCustomizers;
|
||||
|
||||
LettuceConnectionConfiguration(RedisProperties properties,
|
||||
ObjectProvider<RedisStandaloneConfiguration> standaloneConfiguration,
|
||||
ObjectProvider<RedisSentinelConfiguration> sentinelConfigurationProvider,
|
||||
ObjectProvider<RedisClusterConfiguration> clusterConfigurationProvider,
|
||||
ObjectProvider<List<LettuceClientConfigurationBuilderCustomizer>> builderCustomizers) {
|
||||
super(properties, standaloneConfiguration, sentinelConfigurationProvider,
|
||||
clusterConfigurationProvider);
|
||||
super(properties, sentinelConfigurationProvider, clusterConfigurationProvider);
|
||||
this.properties = properties;
|
||||
this.builderCustomizers = builderCustomizers
|
||||
.getIfAvailable(Collections::emptyList);
|
||||
|
|
|
|||
|
|
@ -40,26 +40,19 @@ abstract class RedisConnectionConfiguration {
|
|||
|
||||
private final RedisProperties properties;
|
||||
|
||||
private final RedisStandaloneConfiguration standaloneConfiguration;
|
||||
|
||||
private final RedisSentinelConfiguration sentinelConfiguration;
|
||||
|
||||
private final RedisClusterConfiguration clusterConfiguration;
|
||||
|
||||
protected RedisConnectionConfiguration(RedisProperties properties,
|
||||
ObjectProvider<RedisStandaloneConfiguration> standaloneConfigurationProvider,
|
||||
ObjectProvider<RedisSentinelConfiguration> sentinelConfigurationProvider,
|
||||
ObjectProvider<RedisClusterConfiguration> clusterConfigurationProvider) {
|
||||
this.properties = properties;
|
||||
this.standaloneConfiguration = standaloneConfigurationProvider.getIfAvailable();
|
||||
this.sentinelConfiguration = sentinelConfigurationProvider.getIfAvailable();
|
||||
this.clusterConfiguration = clusterConfigurationProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
protected final RedisStandaloneConfiguration getStandaloneConfig() {
|
||||
if (this.standaloneConfiguration != null) {
|
||||
return this.standaloneConfiguration;
|
||||
}
|
||||
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
|
||||
|
||||
if (StringUtils.hasText(this.properties.getUrl())) {
|
||||
|
|
|
|||
|
|
@ -67,12 +67,8 @@ public class RedisAutoConfigurationJedisTests {
|
|||
|
||||
@Test
|
||||
public void testCustomizeRedisConfiguration() throws Exception {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||
ctx.register(RedisAutoConfiguration.class);
|
||||
ctx.register(CustomConfiguration.class);
|
||||
ctx.refresh();
|
||||
|
||||
JedisConnectionFactory cf = ctx.getBean(JedisConnectionFactory.class);
|
||||
load(CustomConfiguration.class);
|
||||
JedisConnectionFactory cf = this.context.getBean(JedisConnectionFactory.class);
|
||||
assertThat(cf.isUseSsl()).isTrue();
|
||||
}
|
||||
|
||||
|
|
@ -144,8 +140,15 @@ public class RedisAutoConfigurationJedisTests {
|
|||
}
|
||||
|
||||
private void load(String... environment) {
|
||||
load(null, environment);
|
||||
}
|
||||
|
||||
private void load(Class<?> config, String... environment) {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(environment).applyTo(ctx);
|
||||
if (config != null) {
|
||||
ctx.register(config);
|
||||
}
|
||||
ctx.register(RedisAutoConfiguration.class);
|
||||
ctx.refresh();
|
||||
this.context = ctx;
|
||||
|
|
|
|||
|
|
@ -83,12 +83,8 @@ public class RedisAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void testCustomizeRedisConfiguration() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||
ctx.register(RedisAutoConfiguration.class);
|
||||
ctx.register(CustomConfiguration.class);
|
||||
ctx.refresh();
|
||||
|
||||
LettuceConnectionFactory cf = ctx.getBean(LettuceConnectionFactory.class);
|
||||
load(CustomConfiguration.class);
|
||||
LettuceConnectionFactory cf = this.context.getBean(LettuceConnectionFactory.class);
|
||||
assertThat(cf.isUseSsl()).isTrue();
|
||||
}
|
||||
|
||||
|
|
@ -203,8 +199,15 @@ public class RedisAutoConfigurationTests {
|
|||
}
|
||||
|
||||
private void load(String... environment) {
|
||||
load(null, environment);
|
||||
}
|
||||
|
||||
private void load(Class<?> config, String... environment) {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(environment).applyTo(ctx);
|
||||
if (config != null) {
|
||||
ctx.register(config);
|
||||
}
|
||||
ctx.register(RedisAutoConfiguration.class);
|
||||
ctx.refresh();
|
||||
this.context = ctx;
|
||||
|
|
|
|||
Loading…
Reference in New Issue