Skip to content

Commit a32127d

Browse files
committed
fix: stop thread pools when an error occurs during startup
1 parent a29c009 commit a32127d

File tree

1 file changed

+5
-1
lines changed
  • operator-framework-core/src/main/java/io/javaoperatorsdk/operator

1 file changed

+5
-1
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,18 @@ public synchronized void start() {
203203
public void stop() throws OperatorException {
204204
Duration reconciliationTerminationTimeout =
205205
configurationService.reconciliationTerminationTimeout();
206+
207+
// Always stop the executor service manager to prevent dangling threads,
208+
// even if the operator didn't fully start
209+
configurationService.getExecutorServiceManager().stop(reconciliationTerminationTimeout);
210+
206211
if (!started) {
207212
return;
208213
}
209214
log.info(
210215
"Operator SDK {} is shutting down...", configurationService.getVersion().getSdkVersion());
211216
controllerManager.stop();
212217

213-
configurationService.getExecutorServiceManager().stop(reconciliationTerminationTimeout);
214218
leaderElectionManager.stop();
215219
if (configurationService.closeClientOnStop()) {
216220
getKubernetesClient().close();

0 commit comments

Comments
 (0)