Skip to content

Commit e2e68aa

Browse files
committed
Fix resource disposal ordering in LettuceConnectionFactory.
We now close the cluster command executor before cleaning up the connection pools so that we first release all held connections before pruning the connection pools. Previously, the pools were pruned first leading to an attempt to return the connection held by the cluster command executor causing a PoolException. Closes #2330
1 parent 1475069 commit e2e68aa

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,15 @@ public void destroy() {
345345

346346
resetConnection();
347347

348+
if (clusterCommandExecutor != null) {
349+
350+
try {
351+
clusterCommandExecutor.destroy();
352+
} catch (Exception ex) {
353+
log.warn("Cannot properly close cluster command executor", ex);
354+
}
355+
}
356+
348357
dispose(connectionProvider);
349358
dispose(reactiveConnectionProvider);
350359

@@ -360,15 +369,6 @@ public void destroy() {
360369
}
361370
}
362371

363-
if (clusterCommandExecutor != null) {
364-
365-
try {
366-
clusterCommandExecutor.destroy();
367-
} catch (Exception ex) {
368-
log.warn("Cannot properly close cluster command executor", ex);
369-
}
370-
}
371-
372372
this.destroyed = true;
373373
}
374374

0 commit comments

Comments
 (0)