influxdata / influxdata/influxdb-client-java

InfluxQLQueryApiImpl cannot cast JsonNull

Abierto
#808 3 comentarios 0 reacciones 1 asignado Ver en GitHub

@NguyenHoangSon96 ya está trabajando en esto.

Desde el 3/2/2025.

Lenguaje dominante
Java
Estrellas
477
Forks
129
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Hi,
I'm trying to use `queryJSON` method of `InfluxQLQueryApi`.
If I have `null` values resulting from my query, the library fires an exception because of the cast forced to String.

As we can see from line 337 of the class:

```
JsonArray jvals = sobj.get("values").getAsJsonArray();
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 (this.extractor != null) {
String stringVal = je.getAsString();
Object ov = this.extractor.extractValue((String)columnKeys.get(index), stringVal, id, serie.getName());
values.add(ov);
} else {
values.add(je.getAsString());
}

++index;
}

Objects.requireNonNull(serie);
serie.addRecord(new InfluxQLQueryResult.Series.Record(serie, values.toArray()));
}
}
```

When it gets the `null` value, the instruction `String stringVal = je.getAsString();` fires the exception.

Am I doing something wrong?

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.