Skip to content

Commit 5d281ef

Browse files
committed
[grid] Simplify node status response handling in Router
Fix an error is seen in docker-selenium after #16163 Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 58f2268 commit 5d281ef

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

java/src/org/openqa/selenium/grid/node/Node.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,7 @@ protected Node(
199199
.to(() -> new Drain(this, json))
200200
.with(spanDecorator("node.drain").andThen(requiresSecret)),
201201
get("/se/grid/node/status")
202-
.to(
203-
() ->
204-
req -> new HttpResponse().setContent(asJson(Map.of("value", getStatus()))))
202+
.to(() -> req -> new HttpResponse().setContent(asJson(getStatus())))
205203
.with(spanDecorator("node.node_status")),
206204
get("/status").to(() -> new StatusHandler(this)).with(spanDecorator("node.status")));
207205
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static org.openqa.selenium.remote.RemoteTags.SESSION_ID;
2222
import static org.openqa.selenium.remote.RemoteTags.SESSION_ID_EVENT;
2323
import static org.openqa.selenium.remote.http.Contents.asJson;
24+
import static org.openqa.selenium.remote.http.Contents.string;
2425
import static org.openqa.selenium.remote.http.HttpMethod.GET;
2526
import static org.openqa.selenium.remote.tracing.Tags.EXCEPTION;
2627
import static org.openqa.selenium.remote.tracing.Tags.HTTP_REQUEST;
@@ -48,8 +49,8 @@
4849
import org.openqa.selenium.grid.data.NodeStatus;
4950
import org.openqa.selenium.grid.sessionmap.SessionMap;
5051
import org.openqa.selenium.grid.web.ReverseProxyHandler;
51-
import org.openqa.selenium.grid.web.Values;
5252
import org.openqa.selenium.internal.Require;
53+
import org.openqa.selenium.json.Json;
5354
import org.openqa.selenium.remote.ErrorCodec;
5455
import org.openqa.selenium.remote.SessionId;
5556
import org.openqa.selenium.remote.http.ClientConfig;
@@ -256,10 +257,13 @@ private ClientConfig fetchNodeSessionTimeout(URI uri) {
256257
try (HttpClient httpClient = httpClientFactory.createClient(config)) {
257258
HttpRequest statusRequest = new HttpRequest(GET, "/se/grid/node/status");
258259
HttpResponse res = httpClient.execute(statusRequest);
259-
NodeStatus nodeStatus = Values.get(res, NodeStatus.class);
260+
Json json = new Json();
261+
NodeStatus nodeStatus = json.toType(string(res), NodeStatus.class);
260262
if (nodeStatus != null) {
261263
sessionTimeout = nodeStatus.getSessionTimeout();
262264
}
265+
} catch (Exception e) {
266+
LOG.fine("Unable to fetch status for " + uri);
263267
}
264268
LOG.fine("Set read timeout: " + sessionTimeout.toSeconds() + " seconds for " + uri);
265269
config = config.readTimeout(sessionTimeout);

0 commit comments

Comments
 (0)