From 03be1d650200aad0fa8da31dca6cde9b5328032f Mon Sep 17 00:00:00 2001 From: "lambert@arch" Date: Fri, 1 Mar 2024 13:58:50 +0800 Subject: [PATCH] style: rewrite description assign in CheckResultCache in if-else --- .../dashboard/console/health/CheckResultCache.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/CheckResultCache.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/CheckResultCache.java index d84b6b8c..66dcd44d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/CheckResultCache.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/CheckResultCache.java @@ -42,9 +42,10 @@ public void update(String type, Long typeId, HealthCheckStatus status, String re cacheMap.put(type, subMap); } CheckResult oldResult = subMap.get(typeId); - String oldDesc = Objects.isNull(oldResult.getResultDesc()) || oldResult.getResultDesc().isEmpty() ? "" - : oldResult.getResultDesc() + HealthConstant.NEW_LINE_ENDING; - String description = oldDesc + resultDesc; + String description = resultDesc; + if (oldResult.getResultDesc() != null && !oldResult.getResultDesc().isEmpty()) { + description = oldResult.getResultDesc() + HealthConstant.NEW_LINE_ENDING + resultDesc; + } description += " Latency: " + latency.toString() + "ms"; CheckResult result = new CheckResult(status, description, LocalDateTime.now(), latency, oldResult.getConfig()); @@ -57,7 +58,6 @@ public void update(String type, Long typeId, HealthCheckStatus status, String re subMap = new HashMap<>(); cacheMap.put(type, subMap); } - CheckResult resultToUpdate = subMap.get(typeId); subMap.put(typeId, new CheckResult(status, resultDesc, LocalDateTime.now(), latency, config)); }