Skip to content

Commit

Permalink
[Fix-3793] Fix null pointer exception occurs when dinky configures Di…
Browse files Browse the repository at this point in the history
…ngTalk alarm (#3797)

Co-authored-by: luoshangjie <[email protected]>
Co-authored-by: 18216499322 <[email protected]>
  • Loading branch information
3 people authored Sep 10, 2024
1 parent cbf1a3b commit 49cd98d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<User> maintainerInfo = task.getSecondLevelOwners().stream()
.map(id -> {
try {
return userCache.get(id);
} catch (ExecutionException e) {
e.printStackTrace();
}
return null;
})
.collect(Collectors.toList());
List<User> 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)
Expand Down Expand Up @@ -300,6 +296,7 @@ private void addOwnerAlert(AlertInstance alertInstance, User ownerInfo, List<Use
.collect(Collectors.toList()));
break;
case NONE:
break;
default:
log.error("Alert Strategy Type: {} is not supported", value);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ export const EnvConfig = ({ data, onSave, auth }: EnvConfigProps) => {
};

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()
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const GeneralConfig: React.FC<GeneralConfigProps> = (props) => {
onChange={selectChanges}
value={entity.value.toLowerCase()}
disabled={!HasAuthority(auth)}
name={entity.key}
>
{entity.example.map((item: any) => (
<Radio.Button key={item} value={item.toLowerCase()}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
});
Expand Down

0 comments on commit 49cd98d

Please sign in to comment.