influxdata / influxdb-client-java

InfluxDB 2 JVM Based Clients
https://influxdata.github.io/influxdb-client-java/
MIT License
441 stars 129 forks source link

Null returned instead of empty result in `InfluxQLQueryApi.query()` #744

Closed marcinkoziarz closed 4 months ago

marcinkoziarz commented 4 months ago

Steps to reproduce:

  1. Start empty Influxdb instance
  2. Create bucket named "myBucket"
  3. Request list of elements InfluxQLQueryResult result = client.getInfluxQLQueryApi().query(new InfluxQLQuery("show field keys", "myBucket"));

Expected behavior: Code above should return empty result: result.getResults() should return an empty List.

Actual behavior: Code returns null, despite method query(...) being annotated @NonNull.

Specifications:

I believe error is somewhere in AbstractQueryApi class, in bodyConsumer (lines 118+):

        BufferedSource source = body.source();

        while(source.isOpen() && !source.exhausted() && !cancellable.wasCancelled) {
          // consumer won't be executed when body is empty
          consumer.accept(cancellable, source);
        }
bednar commented 4 months ago

Hi @marcinkoziarz,

Thank you for reporting this issue. We will address it in PR #733.

Best regards