From 96e46924bdf0f43a5bfa277c22dd3fd4695eb2a5 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Thu, 8 Aug 2024 15:48:48 +0200 Subject: [PATCH] Default Lettuce shutdownQuietPeriod to zero. Use a lower timeout for faster shutdown. Also, the quiet period is no longer configured through the shutdown timeout. Closes #2945 --- .../lettuce/DefaultLettuceClientConfiguration.java | 4 ++-- .../connection/lettuce/LettuceClientConfiguration.java | 2 +- .../lettuce/LettuceClientConfigurationUnitTests.java | 9 ++++----- .../LettucePoolingClientConfigurationUnitTests.java | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/DefaultLettuceClientConfiguration.java b/src/main/java/org/springframework/data/redis/connection/lettuce/DefaultLettuceClientConfiguration.java index c166000bca..f09f5608cb 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/DefaultLettuceClientConfiguration.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/DefaultLettuceClientConfiguration.java @@ -49,7 +49,7 @@ class DefaultLettuceClientConfiguration implements LettuceClientConfiguration { DefaultLettuceClientConfiguration(boolean useSsl, boolean verifyPeer, boolean startTls, @Nullable ClientResources clientResources, @Nullable ClientOptions clientOptions, @Nullable String clientName, @Nullable ReadFrom readFrom, @Nullable RedisCredentialsProviderFactory redisCredentialsProviderFactory, - Duration timeout, Duration shutdownTimeout, @Nullable Duration shutdownQuietPeriod) { + Duration timeout, Duration shutdownTimeout, Duration shutdownQuietPeriod) { this.useSsl = useSsl; this.verifyPeer = verifyPeer; @@ -61,7 +61,7 @@ class DefaultLettuceClientConfiguration implements LettuceClientConfiguration { this.redisCredentialsProviderFactory = Optional.ofNullable(redisCredentialsProviderFactory); this.timeout = timeout; this.shutdownTimeout = shutdownTimeout; - this.shutdownQuietPeriod = shutdownQuietPeriod != null ? shutdownQuietPeriod : shutdownTimeout; + this.shutdownQuietPeriod = shutdownQuietPeriod; } @Override diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceClientConfiguration.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceClientConfiguration.java index 6372226843..ac1415e504 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceClientConfiguration.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceClientConfiguration.java @@ -175,7 +175,7 @@ class LettuceClientConfigurationBuilder { @Nullable RedisCredentialsProviderFactory redisCredentialsProviderFactory; Duration timeout = Duration.ofSeconds(RedisURI.DEFAULT_TIMEOUT); Duration shutdownTimeout = Duration.ofMillis(100); - @Nullable Duration shutdownQuietPeriod; + Duration shutdownQuietPeriod = Duration.ZERO; LettuceClientConfigurationBuilder() {} diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceClientConfigurationUnitTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceClientConfigurationUnitTests.java index 35c818bb81..c203cbfd80 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceClientConfigurationUnitTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceClientConfigurationUnitTests.java @@ -37,12 +37,11 @@ */ class LettuceClientConfigurationUnitTests { - @Test // DATAREDIS-574, DATAREDIS-576, DATAREDIS-667, DATAREDIS-918 + @Test // DATAREDIS-574, DATAREDIS-576, DATAREDIS-667, DATAREDIS-918, GH-2945 void shouldCreateEmptyConfiguration() { LettuceClientConfiguration configuration = LettuceClientConfiguration.defaultConfiguration(); - assertThat(configuration.isUseSsl()).isFalse(); assertThat(configuration.isVerifyPeer()).isTrue(); assertThat(configuration.isStartTls()).isFalse(); @@ -55,7 +54,7 @@ void shouldCreateEmptyConfiguration() { assertThat(configuration.getClientName()).isEmpty(); assertThat(configuration.getCommandTimeout()).isEqualTo(Duration.ofSeconds(60)); assertThat(configuration.getShutdownTimeout()).isEqualTo(Duration.ofMillis(100)); - assertThat(configuration.getShutdownQuietPeriod()).isEqualTo(Duration.ofMillis(100)); + assertThat(configuration.getShutdownQuietPeriod()).isEqualTo(Duration.ZERO); } @Test // DATAREDIS-574, DATAREDIS-576, DATAREDIS-667 @@ -88,13 +87,13 @@ void shouldConfigureAllProperties() { } @Test // DATAREDIS-881 - void shutdownQuietPeriodShouldDefaultToTimeout() { + void shutdownQuietPeriodShouldDefaultInitialValue() { LettuceClientConfiguration configuration = LettuceClientConfiguration.builder() .shutdownTimeout(Duration.ofSeconds(42)).build(); assertThat(configuration.getShutdownTimeout()).isEqualTo(Duration.ofSeconds(42)); - assertThat(configuration.getShutdownQuietPeriod()).isEqualTo(Duration.ofSeconds(42)); + assertThat(configuration.getShutdownQuietPeriod()).isEqualTo(Duration.ZERO); } @Test // DATAREDIS-576 diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettucePoolingClientConfigurationUnitTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettucePoolingClientConfigurationUnitTests.java index 85215098ff..9f2d2ef30b 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettucePoolingClientConfigurationUnitTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettucePoolingClientConfigurationUnitTests.java @@ -38,7 +38,7 @@ */ class LettucePoolingClientConfigurationUnitTests { - @Test // DATAREDIS-667, DATAREDIS-918 + @Test // DATAREDIS-667, DATAREDIS-918, GH-2945 void shouldCreateEmptyConfiguration() { LettucePoolingClientConfiguration configuration = LettucePoolingClientConfiguration.defaultConfiguration(); @@ -55,7 +55,7 @@ void shouldCreateEmptyConfiguration() { assertThat(configuration.getClientResources()).isEmpty(); assertThat(configuration.getCommandTimeout()).isEqualTo(Duration.ofSeconds(60)); assertThat(configuration.getShutdownTimeout()).isEqualTo(Duration.ofMillis(100)); - assertThat(configuration.getShutdownQuietPeriod()).isEqualTo(Duration.ofMillis(100)); + assertThat(configuration.getShutdownQuietPeriod()).isEqualTo(Duration.ZERO); } @Test // DATAREDIS-667