Merge pull request #6645 from Djooxx/dev-v2

fix-NPE
This commit is contained in:
王嘉豪 2023-11-14 15:39:08 +08:00 committed by GitHub
commit 0bfbd63c6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);
}
} }
} }