From 8052d07ba76fae4674721b9ceffd166494dc94d4 Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Fri, 13 Sep 2024 09:38:22 +0200 Subject: [PATCH] Make sure db index is only set once. See: #2984 --- .../data/redis/connection/lettuce/LettuceConnection.java | 9 +-------- .../connection/lettuce/LettuceConnectionUnitTests.java | 3 ++- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java index e82f459cee..531ddfd438 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java @@ -968,14 +968,7 @@ protected RedisClusterAsyncCommands getAsyncDedicatedConnection( @SuppressWarnings("unchecked") protected StatefulConnection doGetAsyncDedicatedConnection() { - - StatefulConnection connection = getConnectionProvider().getConnection(StatefulConnection.class); - - if (customizedDatabaseIndex()) { - potentiallySelectDatabase(connection, this.dbIndex); - } - - return connection; + return getConnectionProvider().getConnection(StatefulConnection.class); } @Override diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionUnitTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionUnitTests.java index 612367c06c..5dd0eb13c1 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionUnitTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionUnitTests.java @@ -25,6 +25,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; import io.lettuce.core.KeyScanCursor; @@ -188,7 +189,7 @@ void dbIndexShouldBeSetWhenObtainingConnection() { connection.getNativeConnection(); verify(asyncCommandsMock).dispatch(eq(CommandType.SELECT), any(), any()); - verify(commandsMock).select(1); + verifyNoInteractions(commandsMock); } @Test // DATAREDIS-603