From 55d19491159a401638a0e02a821190961ac9827b Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Fri, 24 Mar 2023 10:30:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/hai/common/utils/HttpsUtils.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java b/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java index 453151de..56f2d6ca 100644 --- a/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java +++ b/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java @@ -105,6 +105,7 @@ public class HttpsUtils { apiUrl += param; String result = null; HttpClient httpClient = null; + HttpResponse response = null; try { if (apiUrl.startsWith("https")) { @@ -115,7 +116,7 @@ public class HttpsUtils { } HttpGet httpGet = new HttpGet(apiUrl); - HttpResponse response = httpClient.execute(httpGet); + response = httpClient.execute(httpGet); HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); @@ -126,6 +127,13 @@ public class HttpsUtils { } catch (Exception e) { log.error(e.getMessage(),e); } finally { + if (response != null) { + try { + EntityUtils.consume(response.getEntity()); + } catch (IOException e) { + log.error(e.getMessage(),e); + } + } } return null; }