From 6041de785f6f220b4b7a424cddd99cf145cee3d8 Mon Sep 17 00:00:00 2001 From: yuzhipeng Date: Sat, 12 Oct 2024 16:25:54 +0800 Subject: [PATCH] When override workQueue for the controller should shutdown the original queue incase thread leakage Issue: https://github.com/kubernetes-client/java/issues/3738 Signed-off-by: yuzhipeng --- .../extended/controller/builder/DefaultControllerBuilder.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extended/src/main/java/io/kubernetes/client/extended/controller/builder/DefaultControllerBuilder.java b/extended/src/main/java/io/kubernetes/client/extended/controller/builder/DefaultControllerBuilder.java index 04e35cb2b7..a07fbbe568 100644 --- a/extended/src/main/java/io/kubernetes/client/extended/controller/builder/DefaultControllerBuilder.java +++ b/extended/src/main/java/io/kubernetes/client/extended/controller/builder/DefaultControllerBuilder.java @@ -104,6 +104,9 @@ public DefaultControllerBuilder withName(String controllerName) { * @return the controller builder */ public DefaultControllerBuilder withWorkQueue(RateLimitingQueue workQueue) { + if (this.workQueue != null && !this.workQueue.isShuttingDown()){ + this.workQueue.shutDown(); + } this.workQueue = workQueue; return this; }