Skip to content

Commit 3c1e857

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 1408991 commit 3c1e857

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
@@ -364,6 +364,15 @@ public void destroy() {
364364

365365
resetConnection();
366366

367+
if (clusterCommandExecutor != null) {
368+
369+
try {
370+
clusterCommandExecutor.destroy();
371+
} catch (Exception ex) {
372+
log.warn("Cannot properly close cluster command executor", ex);
373+
}
374+
}
375+
367376
dispose(connectionProvider);
368377
dispose(reactiveConnectionProvider);
369378

@@ -379,15 +388,6 @@ public void destroy() {
379388
}
380389
}
381390

382-
if (clusterCommandExecutor != null) {
383-
384-
try {
385-
clusterCommandExecutor.destroy();
386-
} catch (Exception ex) {
387-
log.warn("Cannot properly close cluster command executor", ex);
388-
}
389-
}
390-
391391
this.destroyed = true;
392392
}
393393

0 commit comments

Comments
 (0)