Skip to content

Commit

Permalink
Fix resource disposal ordering in LettuceConnectionFactory.
Browse files Browse the repository at this point in the history
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 spring-projects#2330
  • Loading branch information
mp911de committed May 24, 2022
1 parent 1475069 commit e2e68aa
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,15 @@ public void destroy() {

resetConnection();

if (clusterCommandExecutor != null) {

try {
clusterCommandExecutor.destroy();
} catch (Exception ex) {
log.warn("Cannot properly close cluster command executor", ex);
}
}

dispose(connectionProvider);
dispose(reactiveConnectionProvider);

Expand All @@ -360,15 +369,6 @@ public void destroy() {
}
}

if (clusterCommandExecutor != null) {

try {
clusterCommandExecutor.destroy();
} catch (Exception ex) {
log.warn("Cannot properly close cluster command executor", ex);
}
}

this.destroyed = true;
}

Expand Down

0 comments on commit e2e68aa

Please sign in to comment.