From e3fbb3f705c7edf895bcaf1224858219635e675d Mon Sep 17 00:00:00 2001 From: cuiweiwei <1261331557@qq.com> Date: Fri, 8 Jan 2021 14:49:44 +0800 Subject: [PATCH] Fix some influxdb plugin bug (#6139) --- CHANGES.md | 1 + .../storage/plugin/influxdb/query/TopNRecordsQuery.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 466d45e97..e4bcd0367 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -53,6 +53,7 @@ Release Notes. * Fix bug that `endpoint-name-grouping.yml` is not customizable in Dockerized case. * Fix bug that istio version metric type on UI template mismatches the otel rule. * Improve ReadWriteSafeCache concurrency read-write performance +* Fix bug that if use JSON as InfluxDB.ResponseFormat then NumberFormatException maybe occur. #### UI * Fix un-removed tags in trace query. diff --git a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/TopNRecordsQuery.java b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/TopNRecordsQuery.java index 7284214a8..4835710b2 100644 --- a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/TopNRecordsQuery.java +++ b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/TopNRecordsQuery.java @@ -101,8 +101,8 @@ public class TopNRecordsQuery implements ITopNRecordsQueryDAO { } private static final Comparator ASCENDING = Comparator.comparingLong( - a -> Long.parseLong(a.getValue())); + a -> ((Number) Double.parseDouble(a.getValue())).longValue()); private static final Comparator DESCENDING = (a, b) -> Long.compare( - Long.parseLong(b.getValue()), Long.parseLong(a.getValue())); + ((Number) Double.parseDouble(b.getValue())).longValue(), ((Number) Double.parseDouble(a.getValue())).longValue()); }