From d144831cf9fe513829ebc41279d8e8ed0d9f2cf6 Mon Sep 17 00:00:00 2001 From: shanjianq <49084314+shanjianq@users.noreply.github.com> Date: Sun, 4 Sep 2022 17:26:24 +0800 Subject: [PATCH] Fix issue 638 (#639) * fix issue #638 * fix issue #638 Co-authored-by: airoger --- .../console/controller/ThreadPoolController.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hippo4j-console/src/main/java/cn/hippo4j/console/controller/ThreadPoolController.java b/hippo4j-console/src/main/java/cn/hippo4j/console/controller/ThreadPoolController.java index 3ed9853a..08153056 100644 --- a/hippo4j-console/src/main/java/cn/hippo4j/console/controller/ThreadPoolController.java +++ b/hippo4j-console/src/main/java/cn/hippo4j/console/controller/ThreadPoolController.java @@ -23,6 +23,7 @@ import cn.hippo4j.common.toolkit.JSONUtil; import cn.hippo4j.common.toolkit.StringUtil; import cn.hippo4j.common.web.base.Result; import cn.hippo4j.common.web.base.Results; +import cn.hippo4j.common.web.exception.ErrorCodeEnum; import cn.hippo4j.config.model.CacheItem; import cn.hippo4j.config.model.biz.threadpool.ThreadPoolDelReqDTO; import cn.hippo4j.config.model.biz.threadpool.ThreadPoolQueryReqDTO; @@ -84,6 +85,19 @@ public class ThreadPoolController { @DeleteMapping("/delete") public Result deletePool(@RequestBody ThreadPoolDelReqDTO reqDTO) { + List> leases = baseInstanceRegistry.listInstance(reqDTO.getItemId()); + Lease first = CollUtil.getFirst(leases); + if (first == null) { + threadPoolService.deletePool(reqDTO); + return Results.success(); + } + InstanceInfo holder = first.getHolder(); + String itemTenantKey = holder.getGroupKey(); + String groupKey = getGroupKey(reqDTO.getTpId(), itemTenantKey); + Map content = ConfigCacheService.getContent(groupKey); + if (!content.isEmpty()) { + return Results.failure(ErrorCodeEnum.SERVICE_ERROR.getCode(), "this thread pool has instances running"); + } threadPoolService.deletePool(reqDTO); return Results.success(); }