Skip to content

Commit

Permalink
Make sure db index is only set once.
Browse files Browse the repository at this point in the history
See: #2984
  • Loading branch information
christophstrobl committed Sep 13, 2024
1 parent feda7dc commit f2a1af6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -961,14 +961,7 @@ protected RedisClusterAsyncCommands<byte[], byte[]> getAsyncDedicatedConnection(

@SuppressWarnings("unchecked")
protected StatefulConnection<byte[], byte[]> doGetAsyncDedicatedConnection() {

StatefulConnection<byte[], byte[]> connection = getConnectionProvider().getConnection(StatefulConnection.class);

if (customizedDatabaseIndex()) {
potentiallySelectDatabase(connection, this.dbIndex);
}

return connection;
return getConnectionProvider().getConnection(StatefulConnection.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f2a1af6

Please sign in to comment.