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 54868c55b7
commit 20cd0e1b6c

View File

@@ -364,6 +364,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);
@@ -379,15 +388,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;
}