Skip to content

Commit e47545a

Browse files
committed
Fix usage before assignment
When new connection is created in doGetAsyncDedicatedConnection(), it is not yet assigned to asyncDedicatedConnection attribute, so it cannot be used in potentiallySelectDatabase() call. It seems that the select call is superfluous anyway here, because the `select()` method call can be made only when the cached dedicated connection is used (not a shared one) and the `select()` method always selects the database immediately on the cached dedicated connection. Therefore it should never be necessary to call select on newly created dedicated connection, because it is either created by `select()` method call or a default database is used. Closes spring-projects#2984 Signed-off-by: Oldřich Jedlička <[email protected]>
1 parent 0f45851 commit e47545a

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -965,13 +965,7 @@ protected RedisClusterAsyncCommands<byte[], byte[]> getAsyncDedicatedConnection(
965965
@SuppressWarnings("unchecked")
966966
protected StatefulConnection<byte[], byte[]> doGetAsyncDedicatedConnection() {
967967

968-
StatefulConnection<byte[], byte[]> connection = getConnectionProvider().getConnection(StatefulConnection.class);
969-
970-
if (customizedDatabaseIndex()) {
971-
potentiallySelectDatabase(this.dbIndex);
972-
}
973-
974-
return connection;
968+
return getConnectionProvider().getConnection(StatefulConnection.class);
975969
}
976970

977971
@Override

0 commit comments

Comments
 (0)