I found issue while reading how Lettuce integration works in this method:
|
protected StatefulConnection<byte[], byte[]> doGetAsyncDedicatedConnection() { |
|
|
|
StatefulConnection<byte[], byte[]> connection = getConnectionProvider().getConnection(StatefulConnection.class); |
|
|
|
if (customizedDatabaseIndex()) { |
|
potentiallySelectDatabase(this.dbIndex); |
|
} |
|
|
|
return connection; |
|
} |
The method creates a new connection, which is stored by the caller into a asyncDedicatedConnection attribute:
|
private StatefulConnection<byte[], byte[]> getOrCreateDedicatedConnection() { |
|
|
|
if (this.asyncDedicatedConnection == null) { |
|
this.asyncDedicatedConnection = doGetAsyncDedicatedConnection(); |
|
} |
|
|
|
return this.asyncDedicatedConnection; |
|
} |
But it looks like the asyncDedicatedConnection is used before assignment in potentiallySelectDatabase() called by doGetAsyncDedicatedConnection():
|
private void potentiallySelectDatabase(int dbIndex) { |
|
|
|
if (asyncDedicatedConnection instanceof StatefulRedisConnection<byte[], byte[]> statefulConnection) { |
|
statefulConnection.sync().select(dbIndex); |
|
} |
|
} |
I found issue while reading how Lettuce integration works in this method:
spring-data-redis/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java
Lines 966 to 975 in 777f079
The method creates a new connection, which is stored by the caller into a
asyncDedicatedConnectionattribute:spring-data-redis/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java
Lines 1026 to 1033 in 777f079
But it looks like the
asyncDedicatedConnectionis used before assignment inpotentiallySelectDatabase()called bydoGetAsyncDedicatedConnection():spring-data-redis/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java
Lines 1068 to 1073 in 777f079