ruanwenjun commented on code in PR #15174:
URL:
https://github.com/apache/dolphinscheduler/pull/15174#discussion_r1396749211
##########
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkSender.java:
##########
@@ -109,12 +108,11 @@ private static CloseableHttpClient getProxyClient(String
proxy, int port, String
HttpHost httpProxy = new HttpHost(proxy, port);
CredentialsProvider provider = new BasicCredentialsProvider();
provider.setCredentials(new AuthScope(httpProxy), new
UsernamePasswordCredentials(user, password));
- return
HttpClients.custom().setRetryHandler(HttpServiceRetryStrategy.retryStrategy)
Review Comment:
You will loss CredentialsProvider here?
##########
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/HttpUtils.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.alert.api;
+
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+
+public class HttpUtils {
+
+ public static final int TIMEOUT_MILLIS = 5000;
+
+ private HttpUtils() {
+ throw new UnsupportedOperationException("This is a utility class and
cannot be instantiated");
+ }
+
+ public static CloseableHttpClient getClient() {
+ RequestConfig requestConfig = RequestConfig.custom()
+ .setConnectTimeout(TIMEOUT_MILLIS)
+ .setConnectionRequestTimeout(TIMEOUT_MILLIS)
+ .setSocketTimeout(TIMEOUT_MILLIS)
+ .build();
+
+ return HttpClients.custom()
+ .setDefaultRequestConfig(requestConfig)
+
.setRetryHandler(HttpServiceRetryStrategy.retryStrategy).build();
+ }
+}
Review Comment:
I am not suggest to provide a basic client utils here, different plugin may
have different client config.
--
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]