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
This commit is contained in:
Mark Paluch
2022-05-24 15:18:11 +02:00
parent 14750691d3
commit e2e68aa572

View File

@@ -345,6 +345,15 @@ public class LettuceConnectionFactory
resetConnection();
if (clusterCommandExecutor != null) {
try {
clusterCommandExecutor.destroy();
} catch (Exception ex) {
log.warn("Cannot properly close cluster command executor", ex);
}
}
dispose(connectionProvider);
dispose(reactiveConnectionProvider);
@@ -360,15 +369,6 @@ public class LettuceConnectionFactory
}
}
if (clusterCommandExecutor != null) {
try {
clusterCommandExecutor.destroy();
} catch (Exception ex) {
log.warn("Cannot properly close cluster command executor", ex);
}
}
this.destroyed = true;
}