From 49cd98d38105c15916aec38298e590f0648b6f9d Mon Sep 17 00:00:00 2001 From: luoshangjie <75019445+18216499322@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:20:31 +0800 Subject: [PATCH] [Fix-3793] Fix null pointer exception occurs when dinky configures DingTalk alarm (#3797) Co-authored-by: luoshangjie Co-authored-by: 18216499322 <18216499322@users.noreply.github.com> --- .../dinky/job/handler/JobAlertHandler.java | 19 ++++++++----------- .../SettingOverView/EnvConfig/index.tsx | 4 ++-- .../SettingOverView/GeneralConfig.tsx | 1 + .../SettingOverView/ResourcesConfig/index.tsx | 4 ++-- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/dinky-admin/src/main/java/org/dinky/job/handler/JobAlertHandler.java b/dinky-admin/src/main/java/org/dinky/job/handler/JobAlertHandler.java index 0ca798db0b..1fe7b08324 100644 --- a/dinky-admin/src/main/java/org/dinky/job/handler/JobAlertHandler.java +++ b/dinky-admin/src/main/java/org/dinky/job/handler/JobAlertHandler.java @@ -49,13 +49,13 @@ import org.dinky.service.impl.AlertRuleServiceImpl; import org.dinky.utils.JsonUtils; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.compress.utils.Lists; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -252,16 +252,12 @@ private void executeAlertAction(Facts facts, AlertRuleDTO alertRuleDTO) throws E if (!Asserts.isNull(task.getAlertGroup())) { // 获取任务的责任人和维护人对应的用户信息|Get the responsible person and maintainer of the task User ownerInfo = userCache.get(task.getFirstLevelOwner()); - List maintainerInfo = task.getSecondLevelOwners().stream() - .map(id -> { - try { - return userCache.get(id); - } catch (ExecutionException e) { - e.printStackTrace(); - } - return null; - }) - .collect(Collectors.toList()); + List maintainerInfo = Lists.newArrayList(); + if (CollectionUtils.isNotEmpty(task.getSecondLevelOwners())) { + for (Integer secondLevelOwner : task.getSecondLevelOwners()) { + maintainerInfo.add(userCache.get(secondLevelOwner)); + } + } AlertGroup alertGroup = task.getAlertGroup(); alertGroup.getInstances().stream() .filter(Objects::nonNull) @@ -300,6 +296,7 @@ private void addOwnerAlert(AlertInstance alertInstance, User ownerInfo, List { }; const selectChange = async (e: RadioChangeEvent) => { - const { value } = e.target; + const { value, name } = e.target; await onSaveHandler({ name: '', example: [], frontType: '', - key: GLOBAL_SETTING_KEYS.SYS_ENV_SETTINGS_TASK_OWNER_LOCK_STRATEGY, + key: name ?? '', note: '', value: value.toString().toLocaleUpperCase() }); diff --git a/dinky-web/src/pages/SettingCenter/GlobalSetting/SettingOverView/GeneralConfig.tsx b/dinky-web/src/pages/SettingCenter/GlobalSetting/SettingOverView/GeneralConfig.tsx index 478237b7eb..5dad1e8077 100644 --- a/dinky-web/src/pages/SettingCenter/GlobalSetting/SettingOverView/GeneralConfig.tsx +++ b/dinky-web/src/pages/SettingCenter/GlobalSetting/SettingOverView/GeneralConfig.tsx @@ -104,6 +104,7 @@ const GeneralConfig: React.FC = (props) => { onChange={selectChanges} value={entity.value.toLowerCase()} disabled={!HasAuthority(auth)} + name={entity.key} > {entity.example.map((item: any) => ( diff --git a/dinky-web/src/pages/SettingCenter/GlobalSetting/SettingOverView/ResourcesConfig/index.tsx b/dinky-web/src/pages/SettingCenter/GlobalSetting/SettingOverView/ResourcesConfig/index.tsx index 8443238faf..a9edb6ec31 100644 --- a/dinky-web/src/pages/SettingCenter/GlobalSetting/SettingOverView/ResourcesConfig/index.tsx +++ b/dinky-web/src/pages/SettingCenter/GlobalSetting/SettingOverView/ResourcesConfig/index.tsx @@ -76,13 +76,13 @@ export const ResourcesConfig = ({ data, onSave, auth }: ResourcesConfigProps) => setLoading(false); }; const selectChange = async (e: RadioChangeEvent) => { - const { value } = e.target; + const { value, name } = e.target; setModel(value); await onSaveHandler({ name: '', example: [], frontType: '', - key: GLOBAL_SETTING_KEYS.SYS_RESOURCE_SETTINGS_BASE_MODEL, + key: name ?? '', note: '', value: value.toString().toLocaleUpperCase() });