Skip to content

Commit d025490

Browse files
committed
[grid] Enabling request retries for session handling
Helps with #9528
1 parent b40e678 commit d025490

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

java/src/org/openqa/selenium/grid/router/HandleSession.java

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

1818
package org.openqa.selenium.grid.router;
1919

20-
import static org.openqa.selenium.remote.HttpSessionId.getSessionId;
21-
import static org.openqa.selenium.remote.RemoteTags.SESSION_ID;
22-
import static org.openqa.selenium.remote.RemoteTags.SESSION_ID_EVENT;
23-
import static org.openqa.selenium.remote.http.Contents.asJson;
24-
import static org.openqa.selenium.remote.tracing.Tags.EXCEPTION;
25-
import static org.openqa.selenium.remote.tracing.Tags.HTTP_REQUEST;
26-
import static org.openqa.selenium.remote.tracing.Tags.HTTP_REQUEST_EVENT;
27-
import static org.openqa.selenium.remote.tracing.Tags.HTTP_RESPONSE;
28-
2920
import com.google.common.cache.Cache;
3021
import com.google.common.cache.CacheBuilder;
3122
import com.google.common.cache.RemovalListener;
@@ -39,6 +30,7 @@
3930
import org.openqa.selenium.internal.Require;
4031
import org.openqa.selenium.net.Urls;
4132
import org.openqa.selenium.remote.SessionId;
33+
import org.openqa.selenium.remote.http.ClientConfig;
4234
import org.openqa.selenium.remote.http.HttpClient;
4335
import org.openqa.selenium.remote.http.HttpHandler;
4436
import org.openqa.selenium.remote.http.HttpRequest;
@@ -60,6 +52,15 @@
6052
import java.util.concurrent.ScheduledExecutorService;
6153
import java.util.concurrent.TimeUnit;
6254

55+
import static org.openqa.selenium.remote.HttpSessionId.getSessionId;
56+
import static org.openqa.selenium.remote.RemoteTags.SESSION_ID;
57+
import static org.openqa.selenium.remote.RemoteTags.SESSION_ID_EVENT;
58+
import static org.openqa.selenium.remote.http.Contents.asJson;
59+
import static org.openqa.selenium.remote.tracing.Tags.EXCEPTION;
60+
import static org.openqa.selenium.remote.tracing.Tags.HTTP_REQUEST;
61+
import static org.openqa.selenium.remote.tracing.Tags.HTTP_REQUEST_EVENT;
62+
import static org.openqa.selenium.remote.tracing.Tags.HTTP_RESPONSE;
63+
6364
class HandleSession implements HttpHandler {
6465

6566
private final Tracer tracer;
@@ -157,7 +158,10 @@ private Callable<HttpHandler> loadSessionId(Tracer tracer, Span span, SessionId
157158
() -> {
158159
Session session = sessions.get(id);
159160
URL url = Urls.fromUri(session.getUri());
160-
HttpClient client = httpClients.get(url, () -> httpClientFactory.createClient(url));
161+
ClientConfig config = ClientConfig.defaultConfig()
162+
.baseUrl(url)
163+
.withRetries();
164+
HttpClient client = httpClients.get(url, () -> httpClientFactory.createClient(config));
161165
return new ReverseProxyHandler(tracer, client);
162166
}
163167
);

0 commit comments

Comments
 (0)