You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2018/10/08 12:54:43 UTC
[incubator-skywalking] 01/01: Avoid null point exception
This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a commit to branch fix/linear-npe
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git
commit 3f1cbcb0beb10ee03e6f9c92bd345c7fbe7a18ed
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Mon Oct 8 20:54:18 2018 +0800
Avoid null point exception
---
.../storage/plugin/elasticsearch/query/MetricQueryEsDAO.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricQueryEsDAO.java
index c9dcf26..ba9d192 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricQueryEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricQueryEsDAO.java
@@ -89,11 +89,14 @@ public class MetricQueryEsDAO extends EsDAO implements IMetricQueryDAO {
IntValues intValues = new IntValues();
for (MultiGetItemResponse itemResponse : response.getResponses()) {
- int value = ((Number)itemResponse.getResponse().getSource().getOrDefault(valueCName, 0)).intValue();
KVInt kvInt = new KVInt();
kvInt.setId(itemResponse.getId());
- kvInt.setValue(value);
+ kvInt.setValue(0);
+ Map<String, Object> source = itemResponse.getResponse().getSource();
+ if (source != null) {
+ kvInt.setValue(((Number)source.getOrDefault(valueCName, 0)).intValue());
+ }
intValues.getValues().add(kvInt);
}
return intValues;