Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

InfluxQLQueryApiImpl cannot cast JsonNull

Đang mở
#808 3 bình luận 0 reaction 1 người được giao Xem trên GitHub

@NguyenHoangSon96 đang làm issue này rồi.

Từ ngày 3/2/2025.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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<Object> values = new ArrayList();
                            JsonArray jae = jval.getAsJsonArray();
                            int index = 0;

                            for(JsonElement je : jae) {
                                List<String> 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?

Ngôn ngữ chính
Java
Star
477
Fork
129
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của influxdata/influxdb-client-java

Tất cả issue của influxdata/influxdb-client-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.