Skip to content

Commit 384a286

Browse files
authored
[java] deprecate the 'native' methods inside the HttpClient interface (#17340)
1 parent 89a97b7 commit 384a286

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

java/AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
See `java/TESTING.md`
1313

1414
## Code conventions
15+
### Interfaces
16+
- New methods added to existing interfaces must provide a default implementation, if possible.
17+
- Interfaces must not expose the native classes of their implementations.
1518

1619
### Logging
1720
```java

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ default void close() {}
4646
* @param request the HTTP request to send
4747
* @param handler the BodyHandler that determines how to handle the response body
4848
* @return a CompletableFuture containing the HTTP response
49+
* @deprecated use JdkHttpClient#httpClient() instead.
4950
*/
51+
@Deprecated(forRemoval = true)
5052
<T> CompletableFuture<java.net.http.HttpResponse<T>> sendAsyncNative(
5153
java.net.http.HttpRequest request, java.net.http.HttpResponse.BodyHandler<T> handler);
5254

@@ -59,7 +61,9 @@ <T> CompletableFuture<java.net.http.HttpResponse<T>> sendAsyncNative(
5961
* @return the HTTP response
6062
* @throws java.io.IOException if an I/O error occurs
6163
* @throws InterruptedException if the operation is interrupted
64+
* @deprecated use JdkHttpClient#httpClient() instead.
6265
*/
66+
@Deprecated(forRemoval = true)
6367
<T> java.net.http.HttpResponse<T> sendNative(
6468
java.net.http.HttpRequest request, java.net.http.HttpResponse.BodyHandler<T> handler)
6569
throws java.io.IOException, InterruptedException;

java/src/org/openqa/selenium/remote/http/jdk/JdkHttpClient.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ protected PasswordAuthentication getPasswordAuthentication() {
158158
this.client = builder.build();
159159
}
160160

161+
/** Will expose the underlying native HttpClient used. */
162+
public java.net.http.HttpClient client() {
163+
return client;
164+
}
165+
161166
@Override
162167
public WebSocket openSocket(HttpRequest request, WebSocket.Listener listener) {
163168
URI uri;

0 commit comments

Comments
 (0)