diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/AbstractImExportServiceImpl.java b/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/AbstractImExportServiceImpl.java index 1a4be941992..1d1a682424d 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/AbstractImExportServiceImpl.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/AbstractImExportServiceImpl.java @@ -135,7 +135,7 @@ private MonitorDto convert(ExportMonitorDTO exportMonitor) { log.debug("exportMonitor.monitor{}", exportMonitor.monitor); if (exportMonitor.monitor != null) { // Add one more null check BeanUtils.copyProperties(exportMonitor.monitor, monitor); - if (exportMonitor.monitor.tags != null) { + if (exportMonitor.monitor.tags != null && !exportMonitor.monitor.tags.isEmpty()) { monitor.setTags(tagService.listTag(new HashSet<>(exportMonitor.monitor.tags)) .stream() .filter(tag -> !(tag.getName().equals(CommonConstants.TAG_MONITOR_ID) || tag.getName().equals(CommonConstants.TAG_MONITOR_NAME))) diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/MonitorServiceImpl.java b/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/MonitorServiceImpl.java index 67dc3e3e380..5127397b756 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/MonitorServiceImpl.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/MonitorServiceImpl.java @@ -89,6 +89,7 @@ public class MonitorServiceImpl implements MonitorService { private static final Long MONITOR_ID_TMP = 1000000000L; public static final String HTTP = "http://"; + public static final String HTTPS = "https://"; public static final String BLANK = ""; public static final String PATTERN_HTTP = "(?i)http://"; @@ -583,7 +584,7 @@ public void deleteMonitor(long id) throws RuntimeException { @Transactional(rollbackFor = Exception.class) public void deleteMonitors(Set ids) throws RuntimeException { List monitors = monitorDao.findMonitorsByIdIn(ids); - if (monitors != null) { + if (!monitors.isEmpty()) { monitorDao.deleteAll(monitors); paramDao.deleteParamsByMonitorIdIn(ids); Set monitorIds = monitors.stream().map(Monitor::getId).collect(Collectors.toSet()); @@ -750,7 +751,10 @@ public void copyMonitors(List ids) { public void updateAppCollectJob(Job job) { List monitors = monitorDao.findMonitorsByAppEquals(job.getApp()) .stream().filter(monitor -> monitor.getStatus() != CommonConstants.UN_MANAGE_CODE) - .collect(Collectors.toList()); + .toList(); + if (monitors.isEmpty()) { + return; + } List monitorBinds = collectorMonitorBindDao.findCollectorMonitorBindsByMonitorIdIn( monitors.stream().map(Monitor::getId).collect(Collectors.toSet())); Map monitorIdCollectorMap = monitorBinds.stream().collect( @@ -775,7 +779,7 @@ public void updateAppCollectJob(Job job) { param.getParamValue(), param.getType())).collect(Collectors.toList()); List paramDefaultValue = appDefine.getParams().stream() .filter(item -> StringUtils.hasText(item.getDefaultValue())) - .collect(Collectors.toList()); + .toList(); paramDefaultValue.forEach(defaultVar -> { if (configmaps.stream().noneMatch(item -> item.getKey().equals(defaultVar.getField()))) { Configmap configmap = new Configmap(defaultVar.getField(), defaultVar.getDefaultValue(), (byte) 1);