From 9047e9d091879d82aef959cc217a471c2a010271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=86=E5=BE=80=E6=98=94=E6=80=9D=E6=9C=AA=E6=9D=A5?= =?UTF-8?q?=E4=B8=B6?= <2075904@qq.com> Date: Thu, 15 Aug 2024 14:23:35 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=20OkHttp=20response=20body=20is=20?= =?UTF-8?q?not=20being=20closed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wechat/pay/java/core/http/okhttp/OkHttpClientAdapter.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/src/main/java/com/wechat/pay/java/core/http/okhttp/OkHttpClientAdapter.java b/core/src/main/java/com/wechat/pay/java/core/http/okhttp/OkHttpClientAdapter.java index a47cec00..4cc09465 100644 --- a/core/src/main/java/com/wechat/pay/java/core/http/okhttp/OkHttpClientAdapter.java +++ b/core/src/main/java/com/wechat/pay/java/core/http/okhttp/OkHttpClientAdapter.java @@ -150,8 +150,7 @@ private OriginalResponse assembleOriginalResponse( @Override protected InputStream innerDownload(HttpRequest httpRequest) { Request okHttpRequest = buildOkHttpRequest(httpRequest); - try { - Response okHttpResponse = okHttpClient.newCall(okHttpRequest).execute(); + try (Response okHttpResponse = okHttpClient.newCall(okHttpRequest).execute()) { if (isInvalidHttpCode(okHttpResponse.code())) { throw new ServiceException(httpRequest, okHttpResponse.code(), ""); }