From d4f3fe98609bb2a8ae1c95d083909cf6434500e0 Mon Sep 17 00:00:00 2001 From: Yuya Ebihara Date: Fri, 8 Nov 2024 11:50:16 +0900 Subject: [PATCH] Enable ErrorProne CanonicalDuration --- .../alluxio/TestAlluxioFileSystem.java | 2 +- .../cassandra/CassandraClientModule.java | 2 +- .../plugin/eventlistener/kafka/TestUtils.java | 18 +++++++++--------- .../plugin/openlineage/MarquezServer.java | 6 +++--- .../plugin/prometheus/PrometheusServer.java | 4 ++-- pom.xml | 1 + 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/trino-filesystem-alluxio/src/test/java/io/trino/filesystem/alluxio/TestAlluxioFileSystem.java b/lib/trino-filesystem-alluxio/src/test/java/io/trino/filesystem/alluxio/TestAlluxioFileSystem.java index 5e6d93954d0e7..94c003ca2e65c 100644 --- a/lib/trino-filesystem-alluxio/src/test/java/io/trino/filesystem/alluxio/TestAlluxioFileSystem.java +++ b/lib/trino-filesystem-alluxio/src/test/java/io/trino/filesystem/alluxio/TestAlluxioFileSystem.java @@ -153,7 +153,7 @@ private static GenericContainer createAlluxioMasterContainer() .withAccessToHost(true) .waitingFor(new LogMessageWaitStrategy() .withRegEx(".*Primary started*\n") - .withStartupTimeout(Duration.ofSeconds(180L))); + .withStartupTimeout(Duration.ofMinutes(3))); return container; } diff --git a/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraClientModule.java b/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraClientModule.java index 0ac8a8ce78613..6afeefc7b9d32 100644 --- a/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraClientModule.java +++ b/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraClientModule.java @@ -138,7 +138,7 @@ public static CassandraSession createCassandraSession( driverConfigLoaderBuilder.withString(DefaultDriverOption.RECONNECTION_POLICY_CLASS, com.datastax.oss.driver.internal.core.connection.ExponentialReconnectionPolicy.class.getName()); driverConfigLoaderBuilder.withDuration(DefaultDriverOption.RECONNECTION_BASE_DELAY, Duration.ofMillis(500)); - driverConfigLoaderBuilder.withDuration(DefaultDriverOption.RECONNECTION_MAX_DELAY, Duration.ofMillis(10_000)); + driverConfigLoaderBuilder.withDuration(DefaultDriverOption.RECONNECTION_MAX_DELAY, Duration.ofSeconds(10)); driverConfigLoaderBuilder.withString(DefaultDriverOption.RETRY_POLICY_CLASS, config.getRetryPolicy().getPolicyClass().getName()); driverConfigLoaderBuilder.withString(DefaultDriverOption.LOAD_BALANCING_POLICY_CLASS, DefaultLoadBalancingPolicy.class.getName()); diff --git a/plugin/trino-kafka-event-listener/src/test/java/io/trino/plugin/eventlistener/kafka/TestUtils.java b/plugin/trino-kafka-event-listener/src/test/java/io/trino/plugin/eventlistener/kafka/TestUtils.java index 70c8264fbd6bb..14e74baeb96b9 100644 --- a/plugin/trino-kafka-event-listener/src/test/java/io/trino/plugin/eventlistener/kafka/TestUtils.java +++ b/plugin/trino-kafka-event-listener/src/test/java/io/trino/plugin/eventlistener/kafka/TestUtils.java @@ -44,7 +44,7 @@ import java.util.Set; import static io.trino.spi.type.TimeZoneKey.UTC_KEY; -import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; public final class TestUtils { @@ -104,20 +104,20 @@ private TestUtils() {} Optional.empty()); splitStatistics = new SplitStatistics( - ofMillis(1000), - ofMillis(2000), - ofMillis(3000), - ofMillis(4000), + ofSeconds(1), + ofSeconds(2), + ofSeconds(3), + ofSeconds(4), 1, 2, Optional.of(Duration.ofMillis(100)), Optional.of(Duration.ofMillis(200))); queryStatistics = new QueryStatistics( - ofMillis(1000), - ofMillis(1000), - ofMillis(1000), - ofMillis(1000), + ofSeconds(1), + ofSeconds(1), + ofSeconds(1), + ofSeconds(1), Optional.empty(), Optional.empty(), Optional.empty(), diff --git a/plugin/trino-openlineage/src/test/java/io/trino/plugin/openlineage/MarquezServer.java b/plugin/trino-openlineage/src/test/java/io/trino/plugin/openlineage/MarquezServer.java index 6237630ed5ff2..c1e707c0e0e3a 100644 --- a/plugin/trino-openlineage/src/test/java/io/trino/plugin/openlineage/MarquezServer.java +++ b/plugin/trino-openlineage/src/test/java/io/trino/plugin/openlineage/MarquezServer.java @@ -81,7 +81,7 @@ public MarquezServer(String version) .withDatabaseName(POSTGRES_DB) .withUsername(POSTGRES_USER) .withPassword(POSTGRES_PASSWORD) - .withStartupTimeout(Duration.ofSeconds(360)); + .withStartupTimeout(Duration.ofMinutes(6)); this.dockerContainerPostgres.start(); closer.register(this.dockerContainerPostgres::close); @@ -104,7 +104,7 @@ public MarquezServer(String version) .waitingFor(Wait.forHttp(MARQUEZ_HEALTCHECK_API) .forPort(MARQUEZ_ADMIN_PORT) .forStatusCode(200)) - .withStartupTimeout(Duration.ofSeconds(360)); + .withStartupTimeout(Duration.ofMinutes(6)); this.dockerContainerAPI.start(); closer.register(this.dockerContainerAPI::close); @@ -115,7 +115,7 @@ public MarquezServer(String version) .dependsOn(this.dockerContainerAPI) .withEnv("MARQUEZ_HOST", MARQUEZ_HOST) .withEnv("MARQUEZ_PORT", String.valueOf(MARQUEZ_PORT)) - .withStartupTimeout(Duration.ofSeconds(360)); + .withStartupTimeout(Duration.ofMinutes(6)); this.dockerWebUIContainerAPI.start(); closer.register(this.dockerWebUIContainerAPI::close); } diff --git a/plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/PrometheusServer.java b/plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/PrometheusServer.java index df938c126f6c7..17cd1642298d6 100644 --- a/plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/PrometheusServer.java +++ b/plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/PrometheusServer.java @@ -45,14 +45,14 @@ public PrometheusServer(String version, boolean enableBasicAuth) this.dockerContainer = new GenericContainer<>("prom/prometheus:" + version) .withExposedPorts(PROMETHEUS_PORT) .waitingFor(Wait.forHttp(PROMETHEUS_QUERY_API).forResponsePredicate(response -> response.contains("\"values\""))) - .withStartupTimeout(Duration.ofSeconds(360)); + .withStartupTimeout(Duration.ofMinutes(6)); // Basic authentication was introduced in v2.24.0 if (enableBasicAuth) { this.dockerContainer .withCommand("--config.file=/etc/prometheus/prometheus.yml", "--web.config.file=/etc/prometheus/web.yml") .withCopyFileToContainer(forClasspathResource("web.yml"), "/etc/prometheus/web.yml") .waitingFor(Wait.forHttp(PROMETHEUS_QUERY_API).forResponsePredicate(response -> response.contains("\"values\"")).withBasicCredentials(USER, PASSWORD)) - .withStartupTimeout(Duration.ofSeconds(360)); + .withStartupTimeout(Duration.ofMinutes(6)); } this.dockerContainer.start(); } diff --git a/pom.xml b/pom.xml index 99c2d3af80b94..81303c0028f82 100644 --- a/pom.xml +++ b/pom.xml @@ -2818,6 +2818,7 @@ -Xep:BoxedPrimitiveConstructor:ERROR \ -Xep:ByteBufferBackingArray:ERROR \ -Xep:CacheLoaderNull:ERROR \ + -Xep:CanonicalDuration:ERROR \ -Xep:CatchAndPrintStackTrace:ERROR \ -Xep:CatchFail:ERROR \ -Xep:ClassCanBeStatic:ERROR \