From fa04ebf9a5483b2ee845202235c33105e047e705 Mon Sep 17 00:00:00 2001 From: MZR <1149963750@qq.com> Date: Thu, 21 Sep 2023 16:11:47 +0800 Subject: [PATCH] Modify the format of polaris in BootstrapConfigProperties --- .../api/BootstrapPropertiesInterface.java | 2 +- .../properties/BootstrapConfigProperties.java | 2 +- .../core/enable/BeforeCheckConfiguration.java | 45 +++++++++++-------- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/kernel/dynamic/api/src/main/java/cn/hippo4j/threadpool/dynamic/api/BootstrapPropertiesInterface.java b/kernel/dynamic/api/src/main/java/cn/hippo4j/threadpool/dynamic/api/BootstrapPropertiesInterface.java index 7392ae72..4f7316da 100644 --- a/kernel/dynamic/api/src/main/java/cn/hippo4j/threadpool/dynamic/api/BootstrapPropertiesInterface.java +++ b/kernel/dynamic/api/src/main/java/cn/hippo4j/threadpool/dynamic/api/BootstrapPropertiesInterface.java @@ -104,7 +104,7 @@ public interface BootstrapPropertiesInterface { /** * Get Polaris. */ - default Map getPolaris() { + default Map getPolaris() { return null; } diff --git a/kernel/dynamic/mode/config/src/main/java/cn/hippo4j/threadpool/dynamic/mode/config/properties/BootstrapConfigProperties.java b/kernel/dynamic/mode/config/src/main/java/cn/hippo4j/threadpool/dynamic/mode/config/properties/BootstrapConfigProperties.java index ab169dfb..1bc87dc0 100644 --- a/kernel/dynamic/mode/config/src/main/java/cn/hippo4j/threadpool/dynamic/mode/config/properties/BootstrapConfigProperties.java +++ b/kernel/dynamic/mode/config/src/main/java/cn/hippo4j/threadpool/dynamic/mode/config/properties/BootstrapConfigProperties.java @@ -79,7 +79,7 @@ public class BootstrapConfigProperties implements BootstrapPropertiesInterface { /** * polaris config */ - private Map polaris; + private Map polaris; /** * Web config diff --git a/threadpool/core/src/main/java/cn/hippo4j/core/enable/BeforeCheckConfiguration.java b/threadpool/core/src/main/java/cn/hippo4j/core/enable/BeforeCheckConfiguration.java index 5d7502a2..06053dc6 100644 --- a/threadpool/core/src/main/java/cn/hippo4j/core/enable/BeforeCheckConfiguration.java +++ b/threadpool/core/src/main/java/cn/hippo4j/core/enable/BeforeCheckConfiguration.java @@ -144,31 +144,38 @@ public class BeforeCheckConfiguration { } } - Map polaris = properties.getPolaris(); + Map polaris = properties.getPolaris(); if (MapUtil.isNotEmpty(polaris)) { - String namespace = polaris.get("namespace"); + String namespace = polaris.get("namespace").toString(); if (StringUtil.isBlank(namespace)) { throw new ConfigEmptyException( - "Web server failed to start. The dynamic thread pool polaris namespace is empty.", + "Web server maybe fail to start. The dynamic thread pool polaris namespace is empty.", "Please check whether the [spring.dynamic.thread-pool.polaris.namespace] configuration is empty or an empty string."); } - String fileGroup = polaris.get("file.group"); - if (StringUtil.isBlank(fileGroup)) { + if (polaris.get("file") instanceof Map) { + Map polarisFile = (Map)polaris.get("file"); + String fileGroup = polarisFile.get("group"); + if (StringUtil.isBlank(fileGroup)) { + throw new ConfigEmptyException( + "Web server maybe fail to start. The dynamic thread pool polaris file group is empty.", + "Please check whether the [spring.dynamic.thread-pool.polaris.file.group] configuration is empty or an empty string."); + } + String fileName = polarisFile.get("name"); + if (StringUtil.isBlank(fileName)) { + throw new ConfigEmptyException( + "Web server maybe fail to start. The dynamic thread pool polaris file name is empty.", + "Please check whether the [spring.dynamic.thread-pool.polaris.file.name] configuration is empty or an empty string."); + } + String fileType = polarisFile.get("type"); + if (StringUtil.isBlank(fileType)) { + throw new ConfigEmptyException( + "Web server maybe fail to start. The dynamic thread pool polaris file type is empty.", + "Please check whether the [spring.dynamic.thread-pool.polaris.file.type] configuration is empty or an empty string."); + } + } else { throw new ConfigEmptyException( - "Web server failed to start. The dynamic thread pool polaris file group is empty.", - "Please check whether the [spring.dynamic.thread-pool.polaris.file.group] configuration is empty or an empty string."); - } - String fileName = polaris.get("file.name"); - if (StringUtil.isBlank(fileName)) { - throw new ConfigEmptyException( - "Web server failed to start. The dynamic thread pool polaris file name is empty.", - "Please check whether the [spring.dynamic.thread-pool.polaris.file.name] configuration is empty or an empty string."); - } - String fileType = polaris.get("file.type"); - if (StringUtil.isBlank(fileType)) { - throw new ConfigEmptyException( - "Web server failed to start. The dynamic thread pool polaris file type is empty.", - "Please check whether the [spring.dynamic.thread-pool.polaris.file.type] configuration is empty or an empty string."); + "Web server maybe fail to start. Lack of the dynamic thread pool polaris file configuration.", + "Please check whether the [spring.dynamic.thread-pool.polaris.file.*] configuration is complete."); } } break;