bowenliang123 commented on code in PR #4228:
URL: https://github.com/apache/kyuubi/pull/4228#discussion_r1094121925


##########
kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/HttpClientFactory.java:
##########
@@ -35,23 +42,35 @@ public class HttpClientFactory {
   public static CloseableHttpClient createHttpClient(RestClientConf conf) {
     RequestConfig requestConfig =
         RequestConfig.custom()
-            .setSocketTimeout(conf.getSocketTimeout())
-            .setConnectTimeout(conf.getConnectTimeout())
+            .setResponseTimeout(conf.getSocketTimeout(), TimeUnit.MILLISECONDS)
             .build();
+    Registry<ConnectionSocketFactory> socketFactoryRegistry;
     SSLConnectionSocketFactory sslSocketFactory;
     try {
       TrustStrategy acceptingTrustStrategy = (cert, authType) -> true;
       SSLContext sslContext =
           SSLContexts.custom().loadTrustMaterial(null, 
acceptingTrustStrategy).build();
       sslSocketFactory = new SSLConnectionSocketFactory(sslContext, 
NoopHostnameVerifier.INSTANCE);
+      socketFactoryRegistry =
+          RegistryBuilder.<ConnectionSocketFactory>create()
+              .register("https", sslSocketFactory)
+              .register("http", new PlainConnectionSocketFactory())
+              .build();
     } catch (Exception e) {
       LOG.error("Error: ", e);
       throw new KyuubiRestException("Failed to create HttpClient", e);
     }
+    BasicHttpClientConnectionManager cm =
+        new BasicHttpClientConnectionManager(socketFactoryRegistry);
+    ConnectionConfig connConfig =
+        ConnectionConfig.custom()
+            .setConnectTimeout(conf.getConnectTimeout(), TimeUnit.MILLISECONDS)
+            .build();
+    cm.setConnectionConfig(connConfig);
 
     return HttpClientBuilder.create()
         .setDefaultRequestConfig(requestConfig)
-        .setSSLSocketFactory(sslSocketFactory)
+        .setConnectionManager(cm)

Review Comment:
   note: `setSSLSocketFactory` method is removed in httpclient5, and migrated 
to set socketFactoryRegistry via the ConnectionManager.



-- 
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