This commit is contained in:
HaHa 2023-11-11 01:35:27 +08:00
parent 7ade926aef
commit a06a156996

View File

@ -200,10 +200,7 @@ public class HttpClientUtil {
* @return 响应结果字符串 * @return 响应结果字符串
*/ */
public static String post(String url, Map<String, String> body, HttpClientConfig config) { public static String post(String url, Map<String, String> body, HttpClientConfig config) {
CloseableHttpClient httpClient = null; try (CloseableHttpClient httpClient = buildHttpClient(url)) {
try {
buildHttpClient(url);
HttpPost httpPost = new HttpPost(url); HttpPost httpPost = new HttpPost(url);
if (config == null) { if (config == null) {
config = new HttpClientConfig(); config = new HttpClientConfig();
@ -231,14 +228,6 @@ public class HttpClientUtil {
} catch (Exception e) { } catch (Exception e) {
logger.error("HttpClient查询失败", e); logger.error("HttpClient查询失败", e);
throw new DEException(SYSTEM_INNER_ERROR.code(), "HttpClient查询失败: " + e.getMessage()); throw new DEException(SYSTEM_INNER_ERROR.code(), "HttpClient查询失败: " + e.getMessage());
} finally {
try {
if(httpClient != null){
httpClient.close();
}
} catch (Exception e) {
logger.error("HttpClient关闭连接失败", e);
}
} }
} }