From 65e9ea5d2b0ada4f0288ec80cf26884f5093b68e Mon Sep 17 00:00:00 2001 From: Gerard de Leeuw Date: Tue, 30 Dec 2025 08:55:46 +0100 Subject: [PATCH] fix: stop thread pools when an error occurs during startup Signed-off-by: Gerard de Leeuw --- .../src/main/java/io/javaoperatorsdk/operator/Operator.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java index 7aa29c98ae..0da3d6742b 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java @@ -203,6 +203,11 @@ public synchronized void start() { public void stop() throws OperatorException { Duration reconciliationTerminationTimeout = configurationService.reconciliationTerminationTimeout(); + + // Always stop the executor service manager to prevent dangling threads, + // even if the operator didn't fully start + configurationService.getExecutorServiceManager().stop(reconciliationTerminationTimeout); + if (!started) { return; } @@ -210,7 +215,6 @@ public void stop() throws OperatorException { "Operator SDK {} is shutting down...", configurationService.getVersion().getSdkVersion()); controllerManager.stop(); - configurationService.getExecutorServiceManager().stop(reconciliationTerminationTimeout); leaderElectionManager.stop(); if (configurationService.closeClientOnStop()) { getKubernetesClient().close();