This is an automated email from the ASF dual-hosted git repository. zhangyuxuan pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/hertzbeat.git
The following commit(s) were added to refs/heads/master by this push: new d70ad75dcc [bugfix] Fix NullPointerException (#2849) d70ad75dcc is described below commit d70ad75dcc1822037fcd02dc856b66d4f5edf36f Author: Ayu <127600988+ayu...@users.noreply.github.com> AuthorDate: Sun Jan 12 22:52:37 2025 +0800 [bugfix] Fix NullPointerException (#2849) Signed-off-by: Ayu <127600988+ayu...@users.noreply.github.com> Signed-off-by: Zhang Yuxuan <1373529...@qq.com> Co-authored-by: Ayu <14359932+lin-ayu...@user.noreply.gitee.com> Co-authored-by: shown <yuluo08290...@gmail.com> Co-authored-by: aias00 <rok...@163.com> Co-authored-by: Zhang Yuxuan <1373529...@qq.com> --- .../collector/dispatch/CommonDispatcher.java | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/hertzbeat-collector/hertzbeat-collector-collector/src/main/java/org/apache/hertzbeat/collector/dispatch/CommonDispatcher.java b/hertzbeat-collector/hertzbeat-collector-collector/src/main/java/org/apache/hertzbeat/collector/dispatch/CommonDispatcher.java index 3dd927321a..4fac35f0f4 100644 --- a/hertzbeat-collector/hertzbeat-collector-collector/src/main/java/org/apache/hertzbeat/collector/dispatch/CommonDispatcher.java +++ b/hertzbeat-collector/hertzbeat-collector-collector/src/main/java/org/apache/hertzbeat/collector/dispatch/CommonDispatcher.java @@ -183,18 +183,21 @@ public class CommonDispatcher implements MetricsTaskDispatch, CollectDataDispatc Job job = timerTask.getJob(); job.constructPriorMetrics(); Set<Metrics> metricsSet = job.getNextCollectMetrics(null, true); - metricsSet.forEach(metrics -> { - MetricsCollect metricsCollect = new MetricsCollect(metrics, timeout, this, - collectorIdentity, unitConvertList); - jobRequestQueue.addJob(metricsCollect); - if (metrics.getPrometheus() != null) { - metricsTimeoutMonitorMap.put(String.valueOf(job.getId()), - new MetricsTime(System.currentTimeMillis(), metrics, timeout)); - } else { - metricsTimeoutMonitorMap.put(job.getId() + "-" + metrics.getName(), - new MetricsTime(System.currentTimeMillis(), metrics, timeout)); - } - }); + // Avoid NullPointerException + if (null != metricsSet){ + metricsSet.forEach(metrics -> { + MetricsCollect metricsCollect = new MetricsCollect(metrics, timeout, this, + collectorIdentity, unitConvertList); + jobRequestQueue.addJob(metricsCollect); + if (metrics.getPrometheus() != null) { + metricsTimeoutMonitorMap.put(String.valueOf(job.getId()), + new MetricsTime(System.currentTimeMillis(), metrics, timeout)); + } else { + metricsTimeoutMonitorMap.put(job.getId() + "-" + metrics.getName(), + new MetricsTime(System.currentTimeMillis(), metrics, timeout)); + } + }); + } } @Override --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@hertzbeat.apache.org For additional commands, e-mail: notifications-h...@hertzbeat.apache.org