From 5f61cfd951d9f51fcffe208024efa472beaadab3 Mon Sep 17 00:00:00 2001 From: alzimmermsft <48699787+alzimmermsft@users.noreply.github.com> Date: Wed, 25 Nov 2020 09:40:47 -0800 Subject: [PATCH] Remove Constant from HttpClient --- .../azure/core/http/jdk/httpclient/JdkAsyncHttpClient.java | 2 +- .../com/azure/core/http/netty/NettyAsyncHttpClient.java | 2 +- .../com/azure/core/http/okhttp/OkHttpAsyncHttpClient.java | 2 +- .../src/main/java/com/azure/core/http/HttpClient.java | 6 ------ .../src/main/java/com/azure/core/http/rest/RestProxy.java | 3 +-- 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/sdk/core/azure-core-http-jdk-httpclient/src/main/java/com/azure/core/http/jdk/httpclient/JdkAsyncHttpClient.java b/sdk/core/azure-core-http-jdk-httpclient/src/main/java/com/azure/core/http/jdk/httpclient/JdkAsyncHttpClient.java index 51206327c38cb..f26a28f73ed36 100644 --- a/sdk/core/azure-core-http-jdk-httpclient/src/main/java/com/azure/core/http/jdk/httpclient/JdkAsyncHttpClient.java +++ b/sdk/core/azure-core-http-jdk-httpclient/src/main/java/com/azure/core/http/jdk/httpclient/JdkAsyncHttpClient.java @@ -57,7 +57,7 @@ public Mono send(HttpRequest request) { @Override public Mono send(HttpRequest request, Context context) { - boolean eagerlyReadResponse = (boolean) context.getData(EAGERLY_READ_RESPONSE_CONTEXT_KEY).orElse(false); + boolean eagerlyReadResponse = (boolean) context.getData("azure-eagerly-read-response").orElse(false); return toJdkHttpRequest(request) .flatMap(jdkRequest -> Mono.fromCompletionStage(jdkHttpClient.sendAsync(jdkRequest, ofPublisher())) diff --git a/sdk/core/azure-core-http-netty/src/main/java/com/azure/core/http/netty/NettyAsyncHttpClient.java b/sdk/core/azure-core-http-netty/src/main/java/com/azure/core/http/netty/NettyAsyncHttpClient.java index 3de4bf7696c8e..11a7d8e336791 100644 --- a/sdk/core/azure-core-http-netty/src/main/java/com/azure/core/http/netty/NettyAsyncHttpClient.java +++ b/sdk/core/azure-core-http-netty/src/main/java/com/azure/core/http/netty/NettyAsyncHttpClient.java @@ -73,7 +73,7 @@ public Mono send(HttpRequest request, Context context) { Objects.requireNonNull(request.getUrl(), "'request.getUrl()' cannot be null."); Objects.requireNonNull(request.getUrl().getProtocol(), "'request.getUrl().getProtocol()' cannot be null."); - boolean eagerlyReadResponse = (boolean) context.getData(EAGERLY_READ_RESPONSE_CONTEXT_KEY).orElse(false); + boolean eagerlyReadResponse = (boolean) context.getData("azure-eagerly-read-response").orElse(false); return nettyClient .request(HttpMethod.valueOf(request.getHttpMethod().toString())) diff --git a/sdk/core/azure-core-http-okhttp/src/main/java/com/azure/core/http/okhttp/OkHttpAsyncHttpClient.java b/sdk/core/azure-core-http-okhttp/src/main/java/com/azure/core/http/okhttp/OkHttpAsyncHttpClient.java index 75f753bfd1255..24cd41f21d0be 100644 --- a/sdk/core/azure-core-http-okhttp/src/main/java/com/azure/core/http/okhttp/OkHttpAsyncHttpClient.java +++ b/sdk/core/azure-core-http-okhttp/src/main/java/com/azure/core/http/okhttp/OkHttpAsyncHttpClient.java @@ -48,7 +48,7 @@ public Mono send(HttpRequest request) { @Override public Mono send(HttpRequest request, Context context) { - boolean eagerlyReadResponse = (boolean) context.getData(EAGERLY_READ_RESPONSE_CONTEXT_KEY).orElse(false); + boolean eagerlyReadResponse = (boolean) context.getData("azure-eagerly-read-response").orElse(false); return Mono.create(sink -> sink.onRequest(value -> { // Using MonoSink::onRequest for back pressure support. diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/http/HttpClient.java b/sdk/core/azure-core/src/main/java/com/azure/core/http/HttpClient.java index 235434fdef4df..86d8565f5def0 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/http/HttpClient.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/http/HttpClient.java @@ -11,12 +11,6 @@ * A generic interface for sending HTTP requests and getting responses. */ public interface HttpClient { - /** - * Key for {@link Context} where the value is a boolean flag that indicates whether the {@link HttpResponse} body - * should be eagerly read and buffered into memory. - */ - String EAGERLY_READ_RESPONSE_CONTEXT_KEY = "azure-eagerly-read-response"; - /** * Send the provided request asynchronously. * diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RestProxy.java b/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RestProxy.java index cd6bdd9d7b60f..bcbc2eca896c4 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RestProxy.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RestProxy.java @@ -52,7 +52,6 @@ import java.util.function.Function; import java.util.function.Supplier; -import static com.azure.core.http.HttpClient.EAGERLY_READ_RESPONSE_CONTEXT_KEY; import static com.azure.core.implementation.serializer.HttpResponseBodyDecoder.isReturnTypeDecodable; /** @@ -124,7 +123,7 @@ public Object invoke(Object proxy, final Method method, Object[] args) { final HttpRequest request = createHttpRequest(methodParser, args); Context context = methodParser.setContext(args) .addData("caller-method", methodParser.getFullyQualifiedMethodName()) - .addData(EAGERLY_READ_RESPONSE_CONTEXT_KEY, isReturnTypeDecodable(methodParser.getReturnType())); + .addData("azure-eagerly-read-response", isReturnTypeDecodable(methodParser.getReturnType())); context = startTracingSpan(method, context); if (request.getBody() != null) {