Skip to content

Commit c928e69

Browse files
committed
Updated on comments
1 parent ec7baba commit c928e69

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/JedisConnectionConfiguration.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ private JedisPoolConfig jedisPoolConfig(RedisProperties.Pool pool) {
113113
config.setMaxTotal(pool.getMaxActive());
114114
config.setMaxIdle(pool.getMaxIdle());
115115
config.setMinIdle(pool.getMinIdle());
116+
if (pool.getTimeBetweenEvictionRuns() != null) {
117+
config.setTimeBetweenEvictionRunsMillis(
118+
pool.getTimeBetweenEvictionRuns().toMillis());
119+
}
116120
if (pool.getMaxWait() != null) {
117121
config.setMaxWaitMillis(pool.getMaxWait().toMillis());
118122
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,10 @@ private GenericObjectPoolConfig<?> getPoolConfig(Pool properties) {
146146
config.setMaxTotal(properties.getMaxActive());
147147
config.setMaxIdle(properties.getMaxIdle());
148148
config.setMinIdle(properties.getMinIdle());
149-
config.setTimeBetweenEvictionRunsMillis(
150-
properties.getTimeBetweenEvictionRuns().toMillis());
149+
if (properties.getTimeBetweenEvictionRuns() != null) {
150+
config.setTimeBetweenEvictionRunsMillis(
151+
properties.getTimeBetweenEvictionRuns().toMillis());
152+
}
151153
if (properties.getMaxWait() != null) {
152154
config.setMaxWaitMillis(properties.getMaxWait().toMillis());
153155
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public static class Pool {
197197
* When positive, the idle object evictor thread starts. When non-positive, no
198198
* idle object evictor thread runs.
199199
*/
200-
private Duration timeBetweenEvictionRuns = Duration.ofMillis(-1);
200+
private Duration timeBetweenEvictionRuns;
201201

202202
public int getMaxIdle() {
203203
return this.maxIdle;

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,23 @@ public void testPasswordInUrlStartsWithColon() {
134134

135135
@Test
136136
public void testRedisConfigurationWithPool() {
137-
this.contextRunner.withPropertyValues("spring.redis.host:foo",
138-
"spring.redis.jedis.pool.min-idle:1",
139-
"spring.redis.jedis.pool.max-idle:4",
140-
"spring.redis.jedis.pool.max-active:16",
141-
"spring.redis.jedis.pool.max-wait:2000").run((context) -> {
137+
this.contextRunner
138+
.withPropertyValues("spring.redis.host:foo",
139+
"spring.redis.jedis.pool.min-idle:1",
140+
"spring.redis.jedis.pool.max-idle:4",
141+
"spring.redis.jedis.pool.max-active:16",
142+
"spring.redis.jedis.pool.max-wait:2000",
143+
"spring.redis.jedis.pool.time-between-eviction-runs:30000")
144+
.run((context) -> {
142145
JedisConnectionFactory cf = context
143146
.getBean(JedisConnectionFactory.class);
144147
assertThat(cf.getHostName()).isEqualTo("foo");
145148
assertThat(cf.getPoolConfig().getMinIdle()).isEqualTo(1);
146149
assertThat(cf.getPoolConfig().getMaxIdle()).isEqualTo(4);
147150
assertThat(cf.getPoolConfig().getMaxTotal()).isEqualTo(16);
148151
assertThat(cf.getPoolConfig().getMaxWaitMillis()).isEqualTo(2000);
152+
assertThat(cf.getPoolConfig().getTimeBetweenEvictionRunsMillis())
153+
.isEqualTo(30000);
149154
});
150155
}
151156

0 commit comments

Comments
 (0)