From f3582c6a746196ecb48fdba76ee0bbc7bc14fda5 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Fri, 12 Jul 2024 14:13:57 +0200 Subject: [PATCH] chore: adds check for null values array in JSON desrializer --- .../client/internal/InfluxQLQueryApiImpl.java | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java b/client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java index d84ac224b7..8d5c7b37ec 100644 --- a/client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java +++ b/client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java @@ -335,26 +335,28 @@ public InfluxQLQueryResult.Result deserialize( serie = new InfluxQLQueryResult.Series(name, columns); } JsonArray jvals = sobj.get("values").getAsJsonArray(); - for (JsonElement jval : jvals) { - List values = new ArrayList<>(); - JsonArray jae = jval.getAsJsonArray(); - int index = 0; - for (JsonElement je : jae) { - List columnKeys = new ArrayList<>(serie.getColumns().keySet()); - if (extractor != null) { - String stringVal = je.getAsString(); - Object ov = extractor.extractValue( - columnKeys.get(index), - stringVal, - id, - serie.getName()); - values.add(ov); - } else { - values.add(je.getAsString()); + if (jvals != null) { + for (JsonElement jval : jvals) { + List values = new ArrayList<>(); + JsonArray jae = jval.getAsJsonArray(); + int index = 0; + for (JsonElement je : jae) { + List columnKeys = new ArrayList<>(serie.getColumns().keySet()); + if (extractor != null) { + String stringVal = je.getAsString(); + Object ov = extractor.extractValue( + columnKeys.get(index), + stringVal, + id, + serie.getName()); + values.add(ov); + } else { + values.add(je.getAsString()); + } + index++; } - index++; + serie.addRecord(serie.new Record(values.toArray())); } - serie.addRecord(serie.new Record(values.toArray())); } series.add(serie); }