funky-eyes commented on code in PR #7492:
URL: https://github.com/apache/incubator-seata/pull/7492#discussion_r2234275032


##########
common/src/main/java/org/apache/seata/common/util/HttpClientUtil.java:
##########
@@ -173,6 +294,46 @@ public static CloseableHttpResponse doGet(
         return null;
     }
 
+    public static CompletableFuture<SimpleHttpResponse> doGetHttp2(String url, 
Map<String, String> headers, int timeout)
+            throws IOException {
+        try (CloseableHttpAsyncClient http2Client = HttpAsyncClients.custom()
+                .setVersionPolicy(HttpVersionPolicy.FORCE_HTTP_2)
+                
.setDefaultRequestConfig(org.apache.hc.client5.http.config.RequestConfig.custom()
+                        .setConnectTimeout(timeout, TimeUnit.MILLISECONDS)
+                        .setResponseTimeout(timeout, TimeUnit.MILLISECONDS)
+                        .setConnectionRequestTimeout(timeout, 
TimeUnit.MILLISECONDS)
+                        .build())
+                .build()) {
+            http2Client.start();
+
+            SimpleHttpRequest request = new SimpleHttpRequest("GET", url);
+            if (headers != null) {
+                headers.forEach(request::setHeader);
+            }
+            CompletableFuture<SimpleHttpResponse> future = new 
CompletableFuture<>();

Review Comment:
   I believe this change is incorrect. This only uses an asynchronous approach 
to populate the response result. Instead, you should define an HttpCallback 
interface (to avoid a strong dependency on HttpClient), which can then be 
implemented by the external caller and passed in. Whenever HttpClient's 
FutureCallback receives a callback, it should invoke the caller's callback 
method.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to