Skip to content

Commit e25900f

Browse files
committed
[java] Update failsafe retry dependency to 3.2.3
1 parent 6c779d2 commit e25900f

File tree

12 files changed

+2282
-2241
lines changed

12 files changed

+2282
-2241
lines changed

‎java/maven_deps.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def selenium_java_deps():
6767
],
6868
),
6969
"net.bytebuddy:byte-buddy:1.12.7",
70-
"net.jodah:failsafe:2.4.4",
70+
"dev.failsafe:failsafe:3.2.3",
7171
"net.sourceforge.htmlunit:htmlunit-core-js:2.57.0",
7272
"org.apache.commons:commons-exec:1.3",
7373
"org.assertj:assertj-core:3.22.0",

‎java/maven_install.json

Lines changed: 2239 additions & 2205 deletions
Large diffs are not rendered by default.

‎java/src/org/openqa/selenium/events/zeromq/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ java_library(
1717
"//java/src/org/openqa/selenium/grid/security",
1818
"//java/src/org/openqa/selenium/json",
1919
artifact("com.google.guava:guava"),
20-
artifact("net.jodah:failsafe"),
20+
artifact("dev.failsafe:failsafe"),
2121
artifact("org.zeromq:jeromq"),
2222
],
2323
)

‎java/src/org/openqa/selenium/events/zeromq/UnboundZmqEventBus.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
import com.google.common.collect.EvictingQueue;
2323

24-
import net.jodah.failsafe.Failsafe;
25-
import net.jodah.failsafe.RetryPolicy;
24+
import dev.failsafe.Failsafe;
25+
import dev.failsafe.RetryPolicy;
2626

2727
import org.openqa.selenium.events.Event;
2828
import org.openqa.selenium.events.EventBus;
@@ -110,12 +110,13 @@ class UnboundZmqEventBus implements EventBus {
110110
String connectionMessage = String.format("Connecting to %s and %s", publishConnection, subscribeConnection);
111111
LOG.info(connectionMessage);
112112

113-
RetryPolicy<Object> retryPolicy = new RetryPolicy<>()
113+
RetryPolicy<Object> retryPolicy = RetryPolicy.builder()
114114
.withMaxAttempts(5)
115115
.withDelay(5, 10, ChronoUnit.SECONDS)
116116
.onFailedAttempt(e -> LOG.log(Level.WARNING, String.format("%s failed", connectionMessage)))
117117
.onRetry(e -> LOG.log(Level.WARNING, String.format("Failure #%s. Retrying.", e.getAttemptCount())))
118-
.onRetriesExceeded(e -> LOG.log(Level.WARNING, "Connection aborted."));
118+
.onRetriesExceeded(e -> LOG.log(Level.WARNING, "Connection aborted."))
119+
.build();
119120

120121
// Access to the zmq socket is safe here: no threads.
121122
Failsafe.with(retryPolicy).run(

‎java/src/org/openqa/selenium/grid/distributor/local/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ java_library(
3030
"//java/src/org/openqa/selenium/json",
3131
"//java/src/org/openqa/selenium/remote",
3232
artifact("com.google.guava:guava"),
33-
artifact("net.jodah:failsafe"),
33+
artifact("dev.failsafe:failsafe"),
3434
],
3535
)

‎java/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
import com.google.common.collect.ImmutableMap;
3333
import com.google.common.collect.ImmutableSet;
3434

35-
import net.jodah.failsafe.Failsafe;
36-
import net.jodah.failsafe.RetryPolicy;
35+
import dev.failsafe.Failsafe;
36+
import dev.failsafe.RetryPolicy;
3737

3838
import org.openqa.selenium.Beta;
3939
import org.openqa.selenium.Capabilities;
@@ -339,11 +339,12 @@ private void updateNodeStatus(NodeStatus status, Runnable healthCheck) {
339339
// Running the health check right after the Node registers itself. We retry the
340340
// execution because the Node might on a complex network topology. For example,
341341
// Kubernetes pods with IPs that take a while before they are reachable.
342-
RetryPolicy<Object> initialHealthCheckPolicy = new RetryPolicy<>()
342+
RetryPolicy<Object> initialHealthCheckPolicy = RetryPolicy.builder()
343343
.withMaxAttempts(-1)
344344
.withMaxDuration(Duration.ofSeconds(90))
345345
.withDelay(Duration.ofSeconds(15))
346-
.abortIf(result -> true);
346+
.abortIf(result -> true)
347+
.build();
347348

348349
LOG.log(getDebugLogLevel(), "Running health check for Node " + status.getExternalUri());
349350
Executors.newSingleThreadExecutor().submit(

‎java/src/org/openqa/selenium/grid/node/httpd/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ java_library(
2323
"//java/src/org/openqa/selenium/netty/server",
2424
"//java/src/org/openqa/selenium/remote",
2525
artifact("com.google.guava:guava"),
26-
artifact("net.jodah:failsafe"),
26+
artifact("dev.failsafe:failsafe"),
2727
],
2828
)

‎java/src/org/openqa/selenium/grid/node/httpd/NodeServer.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import com.google.common.collect.ImmutableSet;
2222
import com.google.common.net.MediaType;
2323

24-
import net.jodah.failsafe.Failsafe;
25-
import net.jodah.failsafe.RetryPolicy;
24+
import dev.failsafe.Failsafe;
25+
import dev.failsafe.RetryPolicy;
2626

2727
import org.openqa.selenium.BuildInfo;
2828
import org.openqa.selenium.cli.CliCommand;
@@ -192,11 +192,12 @@ public NettyServer start() {
192192

193193
// Unlimited attempts, every X seconds, we assume a Node should not need more than Y minutes to register
194194
// X defaults to 10s and Y to 120 seconds, but the user can overwrite that.
195-
RetryPolicy<Object> registrationPolicy = new RetryPolicy<>()
195+
RetryPolicy<Object> registrationPolicy = RetryPolicy.builder()
196196
.withMaxAttempts(-1)
197197
.withMaxDuration(nodeOptions.getRegisterPeriod())
198198
.withDelay(nodeOptions.getRegisterCycle())
199-
.handleResultIf(result -> true);
199+
.handleResultIf(result -> true)
200+
.build();
200201

201202
LOG.info("Starting registration process for Node " + node.getUri());
202203
Executors.newSingleThreadExecutor().submit(() -> {

‎java/src/org/openqa/selenium/remote/http/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ java_export(
1717
"//java/src/org/openqa/selenium:core",
1818
"//java/src/org/openqa/selenium/json",
1919
artifact("com.google.guava:guava"),
20-
artifact("net.jodah:failsafe")
20+
artifact("dev.failsafe:failsafe")
2121
],
2222
)

‎java/src/org/openqa/selenium/remote/http/RetryRequest.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import static java.net.HttpURLConnection.HTTP_UNAVAILABLE;
2323
import static org.openqa.selenium.internal.Debug.getDebugLogLevel;
2424

25-
import net.jodah.failsafe.Failsafe;
26-
import net.jodah.failsafe.RetryPolicy;
25+
import dev.failsafe.Failsafe;
26+
import dev.failsafe.RetryPolicy;
2727

2828
import org.openqa.selenium.TimeoutException;
2929

@@ -36,39 +36,42 @@ public class RetryRequest implements Filter {
3636
private static final Logger LOG = Logger.getLogger(RetryRequest.class.getName());
3737

3838
// Retry on connection error.
39-
private static final RetryPolicy<HttpResponse> connectionFailurePolicy =
40-
new RetryPolicy<HttpResponse>()
39+
private static final RetryPolicy<Object> connectionFailurePolicy =
40+
RetryPolicy.builder()
4141
.handleIf(failure -> failure.getCause() instanceof ConnectException)
4242
.withBackoff(1, 4, ChronoUnit.SECONDS)
4343
.withMaxRetries(3)
4444
.onRetry(e -> LOG.log(
4545
getDebugLogLevel(),
4646
"Connection failure #{0}. Retrying.",
47-
e.getAttemptCount()));
47+
e.getAttemptCount()))
48+
.build();
4849

4950
// Retry on read timeout.
50-
private static final RetryPolicy<HttpResponse> readTimeoutPolicy =
51-
new RetryPolicy<HttpResponse>()
51+
private static final RetryPolicy<Object> readTimeoutPolicy =
52+
RetryPolicy.builder()
5253
.handle(TimeoutException.class)
5354
.withBackoff(1, 4, ChronoUnit.SECONDS)
5455
.withMaxRetries(3)
5556
.onRetry(e -> LOG.log(
5657
getDebugLogLevel(),
5758
"Read timeout #{0}. Retrying.",
58-
e.getAttemptCount()));
59+
e.getAttemptCount()))
60+
.build();
5961

6062
// Retry if server is unavailable or an internal server error occurs without response body.
61-
private static final RetryPolicy<HttpResponse> serverErrorPolicy =
62-
new RetryPolicy<HttpResponse>()
63-
.handleResultIf(response -> response.getStatus() == HTTP_INTERNAL_ERROR &&
64-
Integer.parseInt(response.getHeader(CONTENT_LENGTH)) == 0)
65-
.handleResultIf(response -> response.getStatus() == HTTP_UNAVAILABLE)
63+
private static final RetryPolicy<Object> serverErrorPolicy =
64+
RetryPolicy.builder()
65+
.handleResultIf(response -> ((HttpResponse)response).getStatus() == HTTP_INTERNAL_ERROR &&
66+
Integer.parseInt(((HttpResponse)response).getHeader(CONTENT_LENGTH)) == 0)
67+
.handleResultIf(response -> ((HttpResponse)response).getStatus() == HTTP_UNAVAILABLE)
6668
.withBackoff(1, 2, ChronoUnit.SECONDS)
6769
.withMaxRetries(2)
6870
.onRetry(e -> LOG.log(
6971
getDebugLogLevel(),
7072
"Failure due to server error #{0}. Retrying.",
71-
e.getAttemptCount()));
73+
e.getAttemptCount()))
74+
.build();
7275

7376
@Override
7477
public HttpHandler apply(HttpHandler next) {

‎java/test/org/openqa/selenium/environment/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ java_library(
5555
"//java/src/org/openqa/selenium/remote/http",
5656
"//java/test/org/openqa/selenium/build",
5757
artifact("com.google.guava:guava"),
58-
artifact("net.jodah:failsafe"),
58+
artifact("dev.failsafe:failsafe"),
5959
artifact("org.assertj:assertj-core"),
6060
],
6161
)

‎java/test/org/openqa/selenium/environment/webserver/NettyAppServer.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
import com.google.common.collect.ImmutableMap;
2626

27-
import net.jodah.failsafe.Failsafe;
28-
import net.jodah.failsafe.RetryPolicy;
27+
import dev.failsafe.Failsafe;
28+
import dev.failsafe.RetryPolicy;
2929

3030
import org.openqa.selenium.grid.config.CompoundConfig;
3131
import org.openqa.selenium.grid.config.Config;
@@ -61,15 +61,16 @@ public class NettyAppServer implements AppServer {
6161
private static final Logger LOG = Logger.getLogger(NettyAppServer.class.getName());
6262
private Server<?> server;
6363
private Server<?> secure;
64-
private final RetryPolicy<Object> retryPolicy = new RetryPolicy<>()
64+
private final RetryPolicy<Object> retryPolicy = RetryPolicy.builder()
6565
.withMaxAttempts(5)
6666
.withDelay(100, 1000, ChronoUnit.MILLIS)
6767
.handle(ServerBindException.class)
6868
.onRetry(e -> {
6969
LOG.log(Level.WARNING, String.format("NettyAppServer retry #%s. ", e.getAttemptCount()));
7070
initValues();
7171
})
72-
.onRetriesExceeded(e -> LOG.log(Level.WARNING, "NettyAppServer start aborted."));
72+
.onRetriesExceeded(e -> LOG.log(Level.WARNING, "NettyAppServer start aborted."))
73+
.build();
7374

7475
public NettyAppServer() {
7576
initValues();

0 commit comments

Comments
 (0)