From 78e86140b42b540fc67a8e24ba1bb02f86a25e9a Mon Sep 17 00:00:00 2001 From: weibaohui Date: Wed, 21 Aug 2024 12:59:58 +0800 Subject: [PATCH] fix npe --- BlazorApp/Service/k8s/impl/KubeService.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/BlazorApp/Service/k8s/impl/KubeService.cs b/BlazorApp/Service/k8s/impl/KubeService.cs index f3fc31ef..1e99e9df 100644 --- a/BlazorApp/Service/k8s/impl/KubeService.cs +++ b/BlazorApp/Service/k8s/impl/KubeService.cs @@ -167,6 +167,11 @@ public async Task> ConvertStringToMetrics(string metricString) public async Task> GetMetricsSlis() { var metricString = await GetStringAsync("/metrics/slis"); + if (metricString.IsNullOrWhiteSpace()) + { + return []; + } + var byteArray = Encoding.UTF8.GetBytes(metricString); await using var ms = new MemoryStream(byteArray); var metric = await PrometheusMetricsParser.ParseAsync(ms);