diff --git a/java/src/org/openqa/selenium/grid/web/RoutableHttpClientFactory.java b/java/src/org/openqa/selenium/grid/web/RoutableHttpClientFactory.java index be5342137d944..d3576bd9f922e 100644 --- a/java/src/org/openqa/selenium/grid/web/RoutableHttpClientFactory.java +++ b/java/src/org/openqa/selenium/grid/web/RoutableHttpClientFactory.java @@ -75,21 +75,6 @@ public HttpResponse execute(HttpRequest request) throws UncheckedIOException { public WebSocket openSocket(HttpRequest request, WebSocket.Listener listener) { throw new UnsupportedOperationException("openSocket"); } - - @Override - public - java.util.concurrent.CompletableFuture> sendAsyncNative( - java.net.http.HttpRequest request, - java.net.http.HttpResponse.BodyHandler handler) { - throw new UnsupportedOperationException("sendAsyncNative is not supported"); - } - - @Override - public java.net.http.HttpResponse sendNative( - java.net.http.HttpRequest request, java.net.http.HttpResponse.BodyHandler handler) - throws java.io.IOException, InterruptedException { - throw new UnsupportedOperationException("sendNative is not supported"); - } }; } diff --git a/java/src/org/openqa/selenium/remote/RemoteWebDriverBuilder.java b/java/src/org/openqa/selenium/remote/RemoteWebDriverBuilder.java index 2e6b708268955..e310b95ee573e 100644 --- a/java/src/org/openqa/selenium/remote/RemoteWebDriverBuilder.java +++ b/java/src/org/openqa/selenium/remote/RemoteWebDriverBuilder.java @@ -297,23 +297,6 @@ public WebSocket openSocket(HttpRequest request, WebSocket.Listener listener) { public HttpResponse execute(HttpRequest req) throws UncheckedIOException { return handler.execute(req); } - - @Override - public - java.util.concurrent.CompletableFuture> - sendAsyncNative( - java.net.http.HttpRequest request, - java.net.http.HttpResponse.BodyHandler handler) { - throw new UnsupportedOperationException("sendAsyncNative is not supported"); - } - - @Override - public java.net.http.HttpResponse sendNative( - java.net.http.HttpRequest request, - java.net.http.HttpResponse.BodyHandler handler) - throws java.io.IOException, InterruptedException { - throw new UnsupportedOperationException("sendNative is not supported"); - } }; } }; diff --git a/java/src/org/openqa/selenium/remote/http/HttpClient.java b/java/src/org/openqa/selenium/remote/http/HttpClient.java index 458909441724b..6dafb23ff25c9 100644 --- a/java/src/org/openqa/selenium/remote/http/HttpClient.java +++ b/java/src/org/openqa/selenium/remote/http/HttpClient.java @@ -47,8 +47,11 @@ default void close() {} * @param handler the BodyHandler that determines how to handle the response body * @return a CompletableFuture containing the HTTP response */ - CompletableFuture> sendAsyncNative( - java.net.http.HttpRequest request, java.net.http.HttpResponse.BodyHandler handler); + default CompletableFuture> sendAsyncNative( + java.net.http.HttpRequest request, + java.net.http.HttpResponse.BodyHandler handler) { + throw new UnsupportedOperationException("sendAsyncNative is not supported by this HttpClient implementation"); + } /** * Sends an HTTP request using java.net.http.HttpClient and allows specifying the BodyHandler. @@ -60,10 +63,12 @@ CompletableFuture> sendAsyncNative( * @throws java.io.IOException if an I/O error occurs * @throws InterruptedException if the operation is interrupted */ - java.net.http.HttpResponse sendNative( - java.net.http.HttpRequest request, java.net.http.HttpResponse.BodyHandler handler) - throws java.io.IOException, InterruptedException; - + default java.net.http.HttpResponse sendNative( + java.net.http.HttpRequest request, + java.net.http.HttpResponse.BodyHandler handler) + throws java.io.IOException, InterruptedException { + throw new UnsupportedOperationException("sendNative is not supported by this HttpClient implementation"); + } interface Factory { /** diff --git a/java/test/org/openqa/selenium/grid/testing/PassthroughHttpClient.java b/java/test/org/openqa/selenium/grid/testing/PassthroughHttpClient.java index d77faab75b4ca..f465dff3acdee 100644 --- a/java/test/org/openqa/selenium/grid/testing/PassthroughHttpClient.java +++ b/java/test/org/openqa/selenium/grid/testing/PassthroughHttpClient.java @@ -48,19 +48,6 @@ public WebSocket openSocket(HttpRequest request, WebSocket.Listener listener) { throw new UnsupportedOperationException("openSocket"); } - @Override - public java.util.concurrent.CompletableFuture> sendAsyncNative( - java.net.http.HttpRequest request, java.net.http.HttpResponse.BodyHandler handler) { - throw new UnsupportedOperationException("sendAsyncNative"); - } - - @Override - public java.net.http.HttpResponse sendNative( - java.net.http.HttpRequest request, java.net.http.HttpResponse.BodyHandler handler) - throws java.io.IOException, InterruptedException { - throw new UnsupportedOperationException("sendNative"); - } - public static class Factory implements HttpClient.Factory { private final Routable handler; diff --git a/java/test/org/openqa/selenium/remote/ProtocolHandshakeTest.java b/java/test/org/openqa/selenium/remote/ProtocolHandshakeTest.java index 784b9fe0056ca..d04e845a76a39 100644 --- a/java/test/org/openqa/selenium/remote/ProtocolHandshakeTest.java +++ b/java/test/org/openqa/selenium/remote/ProtocolHandshakeTest.java @@ -194,19 +194,5 @@ String getRequestPayload() { public WebSocket openSocket(HttpRequest request, WebSocket.Listener listener) { throw new UnsupportedOperationException("openSocket"); } - - @Override - public - java.util.concurrent.CompletableFuture> sendAsyncNative( - java.net.http.HttpRequest request, java.net.http.HttpResponse.BodyHandler handler) { - throw new UnsupportedOperationException("sendAsyncNative"); - } - - @Override - public java.net.http.HttpResponse sendNative( - java.net.http.HttpRequest request, java.net.http.HttpResponse.BodyHandler handler) - throws java.io.IOException, InterruptedException { - throw new UnsupportedOperationException("sendNative"); - } } } diff --git a/java/test/org/openqa/selenium/remote/http/NativeHttpClientMethodsTest.java b/java/test/org/openqa/selenium/remote/http/NativeHttpClientMethodsTest.java index 9defc7aa51e74..a3c21905ad054 100644 --- a/java/test/org/openqa/selenium/remote/http/NativeHttpClientMethodsTest.java +++ b/java/test/org/openqa/selenium/remote/http/NativeHttpClientMethodsTest.java @@ -243,6 +243,8 @@ public java.net.http.HttpClient.Version version() { return CompletableFuture.completedFuture(mockResponse); } + + @Override public java.net.http.HttpResponse sendNative( java.net.http.HttpRequest request, java.net.http.HttpResponse.BodyHandler handler)