Repository: influxdata/influxdb-java
Pull request #771 (2021-09-13 03:01:54)

Bump maven-javadoc-plugin from 3.3.0 to 3.3.1
Bumps [maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.3.0 to 3.3.1.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/2d22ccadffc2f22f18e19c2cc6d42fd863b4535d"><code>2d22cca</code></a> [maven-release-plugin] prepare release maven-javadoc-plugin-3.3.1</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/7b7813e5ee6ba59ba75701c4d689337865bdc1f1"><code>7b7813e</code></a> [MJAVADOC-450] Artifacts with a classifier are ignored when looking for resou...</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/0d0e0cc7325fc27b89b7bde0ba2cbe322ff6a040"><code>0d0e0cc</code></a> [MJAVADOC-618] Goal javadoc:aggregate fails with submodules packaged as war</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/a2acaa28f1534b31429589808b630ebe2f08e3d0"><code>a2acaa2</code></a> [MJAVADOC-137] transform verify script from bsh to groovy</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/16ca1192632f2bfc4e10faa4aa24d319957008dc"><code>16ca119</code></a> Clean up slf4j-simple</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/87dbfb209e5b75ead8443d70a0c748d02a4f729b"><code>87dbfb2</code></a> [MJAVADOC-677] Using &quot;requires static transitive&quot; makes javadoc goal fail</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/d770460b765d2a3ccb9594a1a016c6700501861f"><code>d770460</code></a> [MJAVADOC-680] JDK 16+: Error fetching link: ...\target\javadoc-bundle-option...</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/292ebb7eca37a0cebbff8a40a7d85ea915f211ac"><code>292ebb7</code></a> Bump slf4j-simple from 1.7.30 to 1.7.32</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/fe6d738c2f95a3f5a361f0c4ab2eef49d37ae566"><code>fe6d738</code></a> Bump mockito-core from 3.9.0 to 3.12.0</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/d2dd5321dc02e793d87c722224c40d94a607cb51"><code>d2dd532</code></a> [MJAVADOC-679] &quot;Unable to compute stale date&quot; in a directory with accent char...</li>
<li>Additional commits viewable in <a href="https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.3.0...maven-javadoc-plugin-3.3.1">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=org.apache.maven.plugins:maven-javadoc-plugin&package-manager=maven&previous-version=3.3.0&new-version=3.3.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

codecov-commenter: # [Codecov](https://codecov.io/gh/influxdata/influxdb-java/pull/771?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata) Report
> Merging [#771](https://codecov.io/gh/influxdata/influxdb-java/pull/771?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata) (5652d0b) into [master](https://codecov.io/gh/influxdata/influxdb-java/commit/920aa065129763e2aa706a782a19b0f80eaf8ffc?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata) (920aa06) will **decrease** coverage by `0.87%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/influxdata/influxdb-java/pull/771/graphs/tree.svg?width=650&height=150&src=pr&token=QKip8tza8W&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata)](https://codecov.io/gh/influxdata/influxdb-java/pull/771?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata)

```diff
@@             Coverage Diff              @@
##             master     #771      +/-   ##
============================================
- Coverage     54.99%   54.11%   -0.88%     
+ Complexity      390      383       -7     
============================================
  Files            70       70              
  Lines          2575     2574       -1     
  Branches        270      268       -2     
============================================
- Hits           1416     1393      -23     
- Misses         1093     1116      +23     
+ Partials         66       65       -1     
```


| [Impacted Files](https://codecov.io/gh/influxdata/influxdb-java/pull/771?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata) | Coverage Δ | |
|---|---|---|
| [.../influxdb/msgpack/MessagePackConverterFactory.java](https://codecov.io/gh/influxdata/influxdb-java/pull/771/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata#diff-c3JjL21haW4vamF2YS9vcmcvaW5mbHV4ZGIvbXNncGFjay9NZXNzYWdlUGFja0NvbnZlcnRlckZhY3RvcnkuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...uxdb/msgpack/MessagePackResponseBodyConverter.java](https://codecov.io/gh/influxdata/influxdb-java/pull/771/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata#diff-c3JjL21haW4vamF2YS9vcmcvaW5mbHV4ZGIvbXNncGFjay9NZXNzYWdlUGFja1Jlc3BvbnNlQm9keUNvbnZlcnRlci5qYXZh) | `0.00% <0.00%> (-25.00%)` | :arrow_down: |
| [src/main/java/org/influxdb/impl/InfluxDBImpl.java](https://codecov.io/gh/influxdata/influxdb-java/pull/771/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata#diff-c3JjL21haW4vamF2YS9vcmcvaW5mbHV4ZGIvaW1wbC9JbmZsdXhEQkltcGwuamF2YQ==) | `75.39% <0.00%> (-3.89%)` | :arrow_down: |
| [src/main/java/org/influxdb/dto/Query.java](https://codecov.io/gh/influxdata/influxdb-java/pull/771/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata#diff-c3JjL21haW4vamF2YS9vcmcvaW5mbHV4ZGIvZHRvL1F1ZXJ5LmphdmE=) | `65.00% <0.00%> (-2.50%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/influxdata/influxdb-java/pull/771?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/influxdata/influxdb-java/pull/771?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata). Last update [920aa06...5652d0b](https://codecov.io/gh/influxdata/influxdb-java/pull/771?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata).


Patch:
diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml
index d02b08b..9853c67 100644
--- a/.github/workflows/master.yml
+++ b/.github/workflows/master.yml
@@ -11,7 +11,7 @@ jobs:
 
     strategy:
       matrix:
-        jdk: [3-openjdk-16-slim, 3-jdk-14, 3-jdk-8-slim]
+        jdk: [3-openjdk-17-slim, 3-jdk-14, 3-jdk-8-slim]
         influxdb: ['1.1', '1.6', '1.8', '2.0']
 
     steps:
diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml
index d427485..405f23b 100644
--- a/.github/workflows/pr.yml
+++ b/.github/workflows/pr.yml
@@ -11,8 +11,8 @@ jobs:
 
     strategy:
       matrix:
-        jdk: [3-openjdk-16-slim, 3-jdk-14, 3-jdk-8-slim]
-        influxdb: [1.1, 1.6, 1.8, 2.0]
+        jdk: [3-openjdk-17-slim, 3-jdk-14, 3-jdk-8-slim]
+        influxdb: ['1.1', '1.6', '1.8', '2.0']
 
     steps:
       - name: Checkout
@@ -23,6 +23,9 @@ jobs:
         run: '["${{ secrets.DOCKER_REGISTRY_TOKEN }}" == ""] && echo "::set-output name=is_fork_pr::true" || echo "::set-output name=is_fork_pr::false"'
 
       - name: Build project
+        env:
+          MAVEN_JAVA_VERSION: "${{ matrix.jdk }}"
+          INFLUXDB_VERSION: "${{ matrix.influxdb }}"
         run: ./compile-and-test.sh
 
       - name: codecov
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8d74570..eb68501 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,8 @@
 # Changelog
 
-## 2.22 [unreleased]
+## 2.23 [unreleased]
+
+## 2.22 [2021-09-17]
 
 ### Improvements
 
diff --git a/mvn.sh b/mvn.sh
index 938c3df..cd99af3 100755
--- a/mvn.sh
+++ b/mvn.sh
@@ -8,4 +8,4 @@ docker run -it --rm  \
        -v $PWD:/usr/src/mymaven \
        -v $PWD/.m2:/root/.m2 \
        -w /usr/src/mymaven \
-       maven:3-openjdk-16-slim mvn clean "$@"
+       maven:3-openjdk-17-slim mvn clean "$@"
diff --git a/pom.xml b/pom.xml
index 3f71964..7a1c62f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
   <groupId>org.influxdb</groupId>
   <artifactId>influxdb-java</artifactId>
   <packaging>jar</packaging>
-  <version>2.22-SNAPSHOT</version>
+  <version>2.23-SNAPSHOT</version>
   <name>influxdb java bindings</name>
   <description>Java API to access the InfluxDB REST API</description>
   <url>http://www.influxdb.org</url>
@@ -176,7 +176,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-javadoc-plugin</artifactId>
-        <version>3.3.0</version>
+        <version>3.3.1</version>
         <configuration>
           <source>8</source>
         </configuration>
@@ -249,13 +249,13 @@
     <dependency>
       <groupId>org.junit.jupiter</groupId>
       <artifactId>junit-jupiter-engine</artifactId>
-      <version>5.7.2</version>
+      <version>5.8.0</version>
       <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.junit.platform</groupId>
       <artifactId>junit-platform-runner</artifactId>
-      <version>1.7.2</version>
+      <version>1.8.0</version>
       <scope>test</scope>
     </dependency>
     <dependency>
diff --git a/src/main/java/org/influxdb/impl/BatchProcessor.java b/src/main/java/org/influxdb/impl/BatchProcessor.java
index 4430072..28c45b6 100644
--- a/src/main/java/org/influxdb/impl/BatchProcessor.java
+++ b/src/main/java/org/influxdb/impl/BatchProcessor.java
@@ -20,6 +20,7 @@ import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.TimeUnit;
 import java.util.function.BiConsumer;
 import java.util.function.Consumer;
+import java.util.function.Supplier;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -46,6 +47,7 @@ public final class BatchProcessor {
   private final BatchWriter batchWriter;
   private boolean dropActionsOnQueueExhaustion;
   Consumer<Point> droppedActionHandler;
+  Supplier<Double> randomSupplier;
 
   /**
    * The Builder to create a BatchProcessor instance.
@@ -318,20 +320,21 @@ public final class BatchProcessor {
     } else {
         this.queue = new LinkedBlockingQueue<>();
     }
+    this.randomSupplier = Math::random;
 
     Runnable flushRunnable = new Runnable() {
       @Override
       public void run() {
         // write doesn't throw any exceptions
         write();
-        int jitterInterval = (int) (Math.random() * BatchProcessor.this.jitterInterval);
+        int jitterInterval = (int) (randomSupplier.get() * BatchProcessor.this.jitterInterval);
         BatchProcessor.this.scheduler.schedule(this,
                 BatchProcessor.this.flushInterval + jitterInterval, BatchProcessor.this.flushIntervalUnit);
       }
     };
     // Flush at specified Rate
     this.scheduler.schedule(flushRunnable,
-            this.flushInterval + (int) (Math.random() * BatchProcessor.this.jitterInterval),
+            this.flushInterval + (int) (randomSupplier.get() * BatchProcessor.this.jitterInterval),
             this.flushIntervalUnit);
   }
 


Test patch:
diff --git a/compile-and-test.sh b/compile-and-test.sh
index 88f0578..4e903e0 100755
--- a/compile-and-test.sh
+++ b/compile-and-test.sh
@@ -5,7 +5,7 @@
 set -e
 
 DEFAULT_INFLUXDB_VERSION="1.8"
-DEFAULT_MAVEN_JAVA_VERSION="3-openjdk-16-slim"
+DEFAULT_MAVEN_JAVA_VERSION="3-openjdk-17-slim"
 
 INFLUXDB_VERSION="${INFLUXDB_VERSION:-$DEFAULT_INFLUXDB_VERSION}"
 MAVEN_JAVA_VERSION="${MAVEN_JAVA_VERSION:-$DEFAULT_MAVEN_JAVA_VERSION}"
diff --git a/src/test/java/org/influxdb/BatchOptionsTest.java b/src/test/java/org/influxdb/BatchOptionsTest.java
index 351321b..7378746 100644
--- a/src/test/java/org/influxdb/BatchOptionsTest.java
+++ b/src/test/java/org/influxdb/BatchOptionsTest.java
@@ -7,13 +7,13 @@ import org.influxdb.dto.BatchPoints;
 import org.influxdb.dto.Point;
 import org.influxdb.dto.Query;
 import org.influxdb.dto.QueryResult;
-import org.jetbrains.annotations.NotNull;
+import org.influxdb.impl.BatchProcessor;
+import org.influxdb.impl.BatchProcessorTest;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.platform.runner.JUnitPlatform;
 import org.junit.runner.RunWith;
-import org.mockito.Mockito;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 
@@ -21,12 +21,15 @@ import static org.mockito.Mockito.*;
 
 import java.io.IOException;
 import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.TimeUnit;
 import java.util.function.BiConsumer;
 import java.util.function.Consumer;
+import java.util.function.Supplier;
 
 
 @RunWith(JUnitPlatform.class)
@@ -234,15 +237,20 @@ public class BatchOptionsTest {
    * @throws InterruptedException
    */
   @Test
-  public void testJitterDuration() throws InterruptedException {
+  public void testJitterDuration() throws Exception {
 
     String dbName = "write_unittest_" + System.currentTimeMillis();
     try {
-      BatchOptions options = BatchOptions.DEFAULTS.flushDuration(100).jitterDuration(500);
+      // prepare points before start BatchProcessor
+      List<Point> points = prepareSomePoints(0, 19);
+      BatchOptions options = BatchOptions.DEFAULTS.flushDuration(100).jitterDuration(1000);
       influxDB.query(new Query("CREATE DATABASE " + dbName));
       influxDB.setDatabase(dbName);
       influxDB.enableBatch(options);
-      write20Points(influxDB);
+      BatchProcessor batchProcessor = BatchProcessorTest.getPrivateField(influxDB, "batchProcessor");
+      // random always return 1.0 to be sure that first query is null
+      BatchProcessorTest.setPrivateField(batchProcessor, "randomSupplier", (Supplier<Double>) () -> 1.0);
+      points.forEach(influxDB::write);
 
       Thread.sleep(100);
 
@@ -251,7 +259,7 @@ public class BatchOptionsTest {
       Assertions.assertNull(result.getResults().get(0).getError());
 
       //wait for at least one flush
-      Thread.sleep(1000);
+      Thread.sleep(1500);
       result = influxDB.query(new Query("select * from weather", dbName));
       Assertions.assertEquals(20, result.getResults().get(0).getSeries().get(0).getValues().size());
     }
@@ -596,6 +604,7 @@ public class BatchOptionsTest {
 
       verify(spy, times(2)).write(any(BatchPoints.class));
 
+      Thread.sleep(1_500);
       QueryResult result = influxDB.query(new Query("select * from m0", dbName));
       Assertions.assertNotNull(result.getResults().get(0).getSeries());
       Assertions.assertEquals(200, result.getResults().get(0).getSeries().get(0).getValues().size());
@@ -668,14 +677,7 @@ public class BatchOptionsTest {
   }
 
   void writeSomePoints(InfluxDB influxDB, int firstIndex, int lastIndex) {
-    for (int i = firstIndex; i <= lastIndex; i++) {
-      Point point = Point.measurement("weather")
-              .time(i,TimeUnit.HOURS)
-              .addField("temperature", (double) i)
-              .addField("humidity", (double) (i) * 1.1)
-              .addField("uv_index", "moderate").build();
-      influxDB.write(point);
-    }
+    prepareSomePoints(firstIndex, lastIndex).forEach(influxDB::write);
   }
 
   void write20Points(InfluxDB influxDB) {
@@ -686,6 +688,19 @@ public class BatchOptionsTest {
     writeSomePoints(influxDB, 0, n - 1);
   }
 
+  List<Point> prepareSomePoints(int firstIndex, int lastIndex) {
+    List<Point> points = new ArrayList<>();
+    for (int i = firstIndex; i <= lastIndex; i++) {
+      Point point = Point.measurement("weather")
+              .time(i, TimeUnit.HOURS)
+              .addField("temperature", (double) i)
+              .addField("humidity", (double) (i) * 1.1)
+              .addField("uv_index", "moderate").build();
+      points.add(point);
+    }
+    return points;
+  }
+
   private BatchPoints createBatchPoints(String dbName, String measurement, int n) {
     BatchPoints batchPoints = BatchPoints.database(dbName).build();
     for (int i = 1; i <= n; i++) {
diff --git a/src/test/java/org/influxdb/InfluxDBTest.java b/src/test/java/org/influxdb/InfluxDBTest.java
index 60dd666..38b5fcf 100644
--- a/src/test/java/org/influxdb/InfluxDBTest.java
+++ b/src/test/java/org/influxdb/InfluxDBTest.java
@@ -1330,7 +1330,7 @@ public class InfluxDBTest {
         batchPoints.point(point3);
         this.influxDB.write(batchPoints);
 
-        CountDownLatch countDownLatch = new CountDownLatch(3);
+        CountDownLatch countDownLatch = new CountDownLatch(2);
 
         Thread.sleep(2000);
         Query query = new Query("SELECT * FROM disk", dbName, true);
diff --git a/src/test/java/org/influxdb/impl/BatchProcessorTest.java b/src/test/java/org/influxdb/impl/BatchProcessorTest.java
index 213f6d3..df28da3 100644
--- a/src/test/java/org/influxdb/impl/BatchProcessorTest.java
+++ b/src/test/java/org/influxdb/impl/BatchProcessorTest.java
@@ -226,14 +226,27 @@ public class BatchProcessorTest {
       }
     }
 
+    @Test
+    @SuppressWarnings("unchecked")
+    public void randomSupplier() {
+      InfluxDB mockInfluxDB = mock(InfluxDBImpl.class);
+      BatchProcessor batchProcessor = BatchProcessor.builder(mockInfluxDB).actions(Integer.MAX_VALUE)
+                .interval(1, TimeUnit.NANOSECONDS).build();
+
+      Double random = batchProcessor.randomSupplier.get();
+      assertTrue(random >= 0);
+      assertTrue(random < 1);
+      Assertions.assertNotEquals(random, batchProcessor.randomSupplier.get());
+    }
+
     @SuppressWarnings("unchecked")
-    static <T> T getPrivateField(final Object obj, final String name) throws Exception {
+    public static <T> T getPrivateField(final Object obj, final String name) throws Exception {
       Field field = obj.getClass().getDeclaredField(name);
       field.setAccessible(true);
       return (T) field.get(obj);
     }
 
-    static void setPrivateField(final Object obj, final String name, final Object value) throws Exception {
+    public static void setPrivateField(final Object obj, final String name, final Object value) throws Exception {
       Field field = obj.getClass().getDeclaredField(name);
       field.setAccessible(true);
       field.set(obj, value);