diff --git a/java/src/org/openqa/selenium/grid/node/remote/RemoteNode.java b/java/src/org/openqa/selenium/grid/node/remote/RemoteNode.java index dccbb0d5d5a5c..913909b9a93ff 100644 --- a/java/src/org/openqa/selenium/grid/node/remote/RemoteNode.java +++ b/java/src/org/openqa/selenium/grid/node/remote/RemoteNode.java @@ -279,7 +279,7 @@ public Result check() { try { NodeStatus status = getStatus(); - if (!Objects.equals(getId(), status.getNodeId())) { + if (status.getNodeId() != null && !Objects.equals(getId(), status.getNodeId())) { // ensure the original RemoteNode stays DOWN when it has been restarted and registered // again as another RemoteNode with the same externalUri return new Result(DOWN, externalUri + " has unexpected node id"); diff --git a/java/src/org/openqa/selenium/remote/http/jdk/JdkHttpMessages.java b/java/src/org/openqa/selenium/remote/http/jdk/JdkHttpMessages.java index ccf41787ee14c..22d47eda29e19 100644 --- a/java/src/org/openqa/selenium/remote/http/jdk/JdkHttpMessages.java +++ b/java/src/org/openqa/selenium/remote/http/jdk/JdkHttpMessages.java @@ -118,10 +118,15 @@ public java.net.http.HttpRequest createRequest(HttpRequest req, HttpMethod metho private BodyPublisher notChunkingBodyPublisher(HttpRequest req) { Contents.Supplier content = req.getContent(); - // we know the length of the request and use it - BodyPublisher chunking = BodyPublishers.ofInputStream(content); - - return BodyPublishers.fromPublisher(chunking, content.length()); + // Check if the content length is greater than 0 + if (content.length() > 0) { + // we know the length of the request and use it + BodyPublisher chunking = BodyPublishers.ofInputStream(content); + return BodyPublishers.fromPublisher(chunking, content.length()); + } else { + // If the content length is 0, return a BodyPublisher without body + return BodyPublishers.noBody(); + } } public URI getRawUri(HttpRequest req) {