This is an automated email from the ASF dual-hosted git repository. tanjian pushed a commit to branch readHeatMap in repository https://gitbox.apache.org/repos/asf/skywalking.git
commit 2e6e1b3ce9170461933d65224e53024e0927042b Author: JaredTan95 <jian....@daocloud.io> AuthorDate: Tue Jun 9 20:00:31 2020 +0800 fix NPE when fetch empty readHeatMap metrics. --- .../org/apache/skywalking/oap/server/core/query/type/HeatMap.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/HeatMap.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/HeatMap.java index 8483e19..d8b11c1 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/HeatMap.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/HeatMap.java @@ -34,7 +34,7 @@ import org.apache.skywalking.oap.server.core.analysis.metrics.DataTable; @Getter public class HeatMap { private List<HeatMapColumn> values = new ArrayList<>(10); - private List<Bucket> buckets = null; + private List<Bucket> buckets = new ArrayList<>(); public void addBucket(Bucket bucket) { this.buckets.add(bucket); @@ -50,8 +50,7 @@ public class HeatMap { DataTable dataset = new DataTable(rawdata); final List<String> sortedKeys = dataset.sortedKeys(new KeyComparator(true)); - if (buckets == null) { - buckets = new ArrayList<>(dataset.size()); + if (buckets.isEmpty()) { for (int i = 0; i < sortedKeys.size(); i++) { final Bucket bucket = new Bucket(); final String minValue = sortedKeys.get(i);