From 27f721a1f5950260ba987e451212b2b233c11617 Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Fri, 14 Aug 2020 11:48:45 -0400 Subject: [PATCH] Update to resilience4j 1.5.0. --- pom.xml | 2 +- .../configuration/RetryConfiguration.java | 2 +- .../redis/FaultTolerantPubSubConnectionTest.java | 4 ++-- .../redis/FaultTolerantRedisClusterTest.java | 4 ++-- .../tests/http/FaultTolerantHttpClientTest.java | 12 ++++++++---- .../tests/redis/ReplicatedJedisPoolTest.java | 9 ++++----- .../textsecuregcm/tests/storage/AccountsTest.java | 8 ++------ .../textsecuregcm/tests/storage/KeysTest.java | 4 ++-- 8 files changed, 22 insertions(+), 23 deletions(-) diff --git a/pom.xml b/pom.xml index 1a93cc3b2..874c93571 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ 2.0.10 - 0.14.1 + 1.5.0 2.25.1 UTF-8 diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/RetryConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/RetryConfiguration.java index a5dc689ad..13aa9cb84 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/RetryConfiguration.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/RetryConfiguration.java @@ -12,7 +12,7 @@ public class RetryConfiguration { @JsonProperty @Min(1) - private int maxAttempts = RetryConfig.DEFAULT_MAX_ATTEMPTS; + private int maxAttempts = 3; @JsonProperty @Min(1) diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/redis/FaultTolerantPubSubConnectionTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/redis/FaultTolerantPubSubConnectionTest.java index 5449cc82a..969187904 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/redis/FaultTolerantPubSubConnectionTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/redis/FaultTolerantPubSubConnectionTest.java @@ -1,6 +1,6 @@ package org.whispersystems.textsecuregcm.redis; -import io.github.resilience4j.circuitbreaker.CircuitBreakerOpenException; +import io.github.resilience4j.circuitbreaker.CallNotPermittedException; import io.lettuce.core.RedisException; import io.lettuce.core.cluster.pubsub.StatefulRedisClusterPubSubConnection; import io.lettuce.core.cluster.pubsub.api.sync.RedisClusterPubSubCommands; @@ -47,7 +47,7 @@ public class FaultTolerantPubSubConnectionTest { assertThrows(RedisException.class, () -> faultTolerantPubSubConnection.withPubSubConnection(connection -> connection.sync().get("OH NO"))); - assertThrows(CircuitBreakerOpenException.class, + assertThrows(CallNotPermittedException.class, () -> faultTolerantPubSubConnection.withPubSubConnection(connection -> connection.sync().get("OH NO"))); } } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/redis/FaultTolerantRedisClusterTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/redis/FaultTolerantRedisClusterTest.java index 6af06fcb3..488080b06 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/redis/FaultTolerantRedisClusterTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/redis/FaultTolerantRedisClusterTest.java @@ -1,6 +1,6 @@ package org.whispersystems.textsecuregcm.redis; -import io.github.resilience4j.circuitbreaker.CircuitBreakerOpenException; +import io.github.resilience4j.circuitbreaker.CallNotPermittedException; import io.lettuce.core.RedisException; import io.lettuce.core.cluster.RedisClusterClient; import io.lettuce.core.cluster.api.StatefulRedisClusterConnection; @@ -54,7 +54,7 @@ public class FaultTolerantRedisClusterTest { assertThrows(RedisException.class, () -> faultTolerantCluster.withCluster(connection -> connection.sync().get("OH NO"))); - assertThrows(CircuitBreakerOpenException.class, + assertThrows(CallNotPermittedException.class, () -> faultTolerantCluster.withCluster(connection -> connection.sync().get("OH NO"))); } } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/http/FaultTolerantHttpClientTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/http/FaultTolerantHttpClientTest.java index 2c3e3a386..dcc71379f 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/http/FaultTolerantHttpClientTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/http/FaultTolerantHttpClientTest.java @@ -1,6 +1,7 @@ package org.whispersystems.textsecuregcm.tests.http; import com.github.tomakehurst.wiremock.junit.WireMockRule; +import io.github.resilience4j.circuitbreaker.CallNotPermittedException; import org.junit.Rule; import org.junit.Test; import org.whispersystems.textsecuregcm.configuration.CircuitBreakerConfiguration; @@ -15,9 +16,12 @@ import java.net.http.HttpResponse; import java.util.concurrent.CompletionException; import java.util.concurrent.Executors; -import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.verify; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; -import io.github.resilience4j.circuitbreaker.CircuitBreakerOpenException; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; public class FaultTolerantHttpClientTest { @@ -124,7 +128,7 @@ public class FaultTolerantHttpClientTest { client.sendAsync(request, HttpResponse.BodyHandlers.ofString()).join(); throw new AssertionError("Should have failed!"); } catch (CompletionException e) { - assertThat(e.getCause()).isInstanceOf(CircuitBreakerOpenException.class); + assertThat(e.getCause()).isInstanceOf(CallNotPermittedException.class); // good } @@ -142,7 +146,7 @@ public class FaultTolerantHttpClientTest { client.sendAsync(request, HttpResponse.BodyHandlers.ofString()).join(); throw new AssertionError("Should have failed!"); } catch (CompletionException e) { - assertThat(e.getCause()).isInstanceOf(CircuitBreakerOpenException.class); + assertThat(e.getCause()).isInstanceOf(CallNotPermittedException.class); // good } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/redis/ReplicatedJedisPoolTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/redis/ReplicatedJedisPoolTest.java index ce72a1527..6de3cf44f 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/redis/ReplicatedJedisPoolTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/redis/ReplicatedJedisPoolTest.java @@ -1,5 +1,6 @@ package org.whispersystems.textsecuregcm.tests.redis; +import io.github.resilience4j.circuitbreaker.CallNotPermittedException; import org.junit.Test; import org.whispersystems.textsecuregcm.configuration.CircuitBreakerConfiguration; import org.whispersystems.textsecuregcm.redis.ReplicatedJedisPool; @@ -8,8 +9,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; -import io.github.resilience4j.circuitbreaker.CircuitBreaker; -import io.github.resilience4j.circuitbreaker.CircuitBreakerOpenException; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*; import redis.clients.jedis.Jedis; @@ -136,7 +135,7 @@ public class ReplicatedJedisPoolTest { try { replicatedJedisPool.getWriteResource(); throw new AssertionError(); - } catch (CircuitBreakerOpenException e) { + } catch (CallNotPermittedException e) { // good } } @@ -176,7 +175,7 @@ public class ReplicatedJedisPoolTest { try { replicatedJedisPool.getWriteResource(); throw new AssertionError(); - } catch (CircuitBreakerOpenException e) { + } catch (CallNotPermittedException e) { // good } @@ -192,7 +191,7 @@ public class ReplicatedJedisPoolTest { try { replicatedJedisPool.getWriteResource(); throw new AssertionError(); - } catch (CircuitBreakerOpenException e) { + } catch (CallNotPermittedException e) { // good } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountsTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountsTest.java index 23955499c..37dcc512b 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountsTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountsTest.java @@ -4,7 +4,7 @@ import com.fasterxml.uuid.UUIDComparator; import com.opentable.db.postgres.embedded.LiquibasePreparer; import com.opentable.db.postgres.junit.EmbeddedPostgresRules; import com.opentable.db.postgres.junit.PreparedDbRule; -import org.jdbi.v3.core.HandleCallback; +import io.github.resilience4j.circuitbreaker.CallNotPermittedException; import org.jdbi.v3.core.HandleConsumer; import org.jdbi.v3.core.Jdbi; import org.jdbi.v3.core.transaction.TransactionException; @@ -18,8 +18,6 @@ import org.whispersystems.textsecuregcm.storage.Accounts; import org.whispersystems.textsecuregcm.storage.Device; import org.whispersystems.textsecuregcm.storage.FaultTolerantDatabase; import org.whispersystems.textsecuregcm.storage.mappers.AccountRowMapper; -import org.whispersystems.textsecuregcm.util.Conversions; -import org.whispersystems.textsecuregcm.util.Util; import java.io.IOException; import java.sql.PreparedStatement; @@ -28,7 +26,6 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Optional; @@ -36,7 +33,6 @@ import java.util.Random; import java.util.Set; import java.util.UUID; -import io.github.resilience4j.circuitbreaker.CircuitBreakerOpenException; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; @@ -251,7 +247,7 @@ public class AccountsTest { try { accounts.update(account); throw new AssertionError(); - } catch (CircuitBreakerOpenException e) { + } catch (CallNotPermittedException e) { // good } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/KeysTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/KeysTest.java index 614445ab2..882c7388a 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/KeysTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/KeysTest.java @@ -3,7 +3,7 @@ package org.whispersystems.textsecuregcm.tests.storage; import com.opentable.db.postgres.embedded.LiquibasePreparer; import com.opentable.db.postgres.junit.EmbeddedPostgresRules; import com.opentable.db.postgres.junit.PreparedDbRule; -import io.github.resilience4j.circuitbreaker.CircuitBreakerOpenException; +import io.github.resilience4j.circuitbreaker.CallNotPermittedException; import org.jdbi.v3.core.HandleConsumer; import org.jdbi.v3.core.Jdbi; import org.jdbi.v3.core.statement.UnableToExecuteStatementException; @@ -321,7 +321,7 @@ public class KeysTest { try { keys.store("+14152222222", 1, deviceOnePreKeys); throw new AssertionError(); - } catch (CircuitBreakerOpenException e) { + } catch (CallNotPermittedException e) { // good }