Skip to content

Commit 31dbba0

Browse files
Make sure db index is only set once.
See: #2984
1 parent ab70114 commit 31dbba0

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

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

+1-8
Original file line numberDiff line numberDiff line change
@@ -961,14 +961,7 @@ protected RedisClusterAsyncCommands<byte[], byte[]> getAsyncDedicatedConnection(
961961

962962
@SuppressWarnings("unchecked")
963963
protected StatefulConnection<byte[], byte[]> doGetAsyncDedicatedConnection() {
964-
965-
StatefulConnection<byte[], byte[]> connection = getConnectionProvider().getConnection(StatefulConnection.class);
966-
967-
if (customizedDatabaseIndex()) {
968-
potentiallySelectDatabase(connection, this.dbIndex);
969-
}
970-
971-
return connection;
964+
return getConnectionProvider().getConnection(StatefulConnection.class);
972965
}
973966

974967
@Override

src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionUnitTests.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import static org.mockito.Mockito.mock;
2626
import static org.mockito.Mockito.times;
2727
import static org.mockito.Mockito.verify;
28+
import static org.mockito.Mockito.verifyNoInteractions;
2829
import static org.mockito.Mockito.when;
2930

3031
import io.lettuce.core.KeyScanCursor;
@@ -188,7 +189,7 @@ void dbIndexShouldBeSetWhenObtainingConnection() {
188189
connection.getNativeConnection();
189190

190191
verify(asyncCommandsMock).dispatch(eq(CommandType.SELECT), any(), any());
191-
verify(commandsMock).select(1);
192+
verifyNoInteractions(commandsMock);
192193
}
193194

194195
@Test // DATAREDIS-603

0 commit comments

Comments
 (0)