Skip to content

Commit 4def8fe

Browse files
committed
[java] Fixing RetryRequestTest
Also, removing backoff policy.
1 parent 42f054e commit 4def8fe

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,19 @@
1717

1818
package org.openqa.selenium.remote.http;
1919

20-
import static com.google.common.net.HttpHeaders.CONTENT_LENGTH;
21-
import static java.net.HttpURLConnection.HTTP_INTERNAL_ERROR;
22-
import static java.net.HttpURLConnection.HTTP_UNAVAILABLE;
23-
import static org.openqa.selenium.internal.Debug.getDebugLogLevel;
20+
import org.openqa.selenium.TimeoutException;
2421

2522
import dev.failsafe.Failsafe;
2623
import dev.failsafe.RetryPolicy;
2724

28-
import org.openqa.selenium.TimeoutException;
29-
3025
import java.net.ConnectException;
31-
import java.time.temporal.ChronoUnit;
3226
import java.util.logging.Logger;
3327

28+
import static com.google.common.net.HttpHeaders.CONTENT_LENGTH;
29+
import static java.net.HttpURLConnection.HTTP_INTERNAL_ERROR;
30+
import static java.net.HttpURLConnection.HTTP_UNAVAILABLE;
31+
import static org.openqa.selenium.internal.Debug.getDebugLogLevel;
32+
3433
public class RetryRequest implements Filter {
3534

3635
private static final Logger LOG = Logger.getLogger(RetryRequest.class.getName());
@@ -39,7 +38,6 @@ public class RetryRequest implements Filter {
3938
private static final RetryPolicy<Object> connectionFailurePolicy =
4039
RetryPolicy.builder()
4140
.handleIf(failure -> failure.getCause() instanceof ConnectException)
42-
.withBackoff(1, 4, ChronoUnit.SECONDS)
4341
.withMaxRetries(3)
4442
.onRetry(e -> LOG.log(
4543
getDebugLogLevel(),
@@ -51,7 +49,6 @@ public class RetryRequest implements Filter {
5149
private static final RetryPolicy<Object> readTimeoutPolicy =
5250
RetryPolicy.builder()
5351
.handle(TimeoutException.class)
54-
.withBackoff(1, 4, ChronoUnit.SECONDS)
5552
.withMaxRetries(3)
5653
.onRetry(e -> LOG.log(
5754
getDebugLogLevel(),
@@ -65,7 +62,6 @@ public class RetryRequest implements Filter {
6562
.handleResultIf(response -> ((HttpResponse)response).getStatus() == HTTP_INTERNAL_ERROR &&
6663
Integer.parseInt(((HttpResponse)response).getHeader(CONTENT_LENGTH)) == 0)
6764
.handleResultIf(response -> ((HttpResponse)response).getStatus() == HTTP_UNAVAILABLE)
68-
.withBackoff(1, 2, ChronoUnit.SECONDS)
6965
.withMaxRetries(2)
7066
.onRetry(e -> LOG.log(
7167
getDebugLogLevel(),

java/test/org/openqa/selenium/remote/http/RetryRequestTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.openqa.selenium.remote.http;
1919

2020
import com.google.common.collect.ImmutableMap;
21+
2122
import org.junit.Before;
2223
import org.junit.Test;
2324
import org.openqa.selenium.environment.webserver.AppServer;
@@ -45,6 +46,7 @@ public class RetryRequestTest {
4546
public void setUp() throws MalformedURLException {
4647
ClientConfig config = ClientConfig.defaultConfig()
4748
.baseUrl(URI.create("http://localhost:2345").toURL())
49+
.withRetries()
4850
.readTimeout(Duration.ofSeconds(1));
4951
client = new NettyClient.Factory().createClient(config);
5052
}

0 commit comments

Comments
 (0)