Skip to content

Commit d17f113

Browse files
committed
fix potential resource leak
1 parent dafbe07 commit d17f113

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/QrCodeRequestExecutor.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public File execute(CloseableHttpClient httpclient, HttpHost httpProxy, String u
4646
httpGet.setConfig(config);
4747
}
4848

49-
try (CloseableHttpResponse response = httpclient.execute(httpGet)) {
49+
try (CloseableHttpResponse response = httpclient.execute(httpGet);
50+
InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response);) {
5051
Header[] contentTypeHeader = response.getHeaders("Content-Type");
5152
if (contentTypeHeader != null && contentTypeHeader.length > 0) {
5253
// 出错
@@ -55,8 +56,6 @@ public File execute(CloseableHttpClient httpclient, HttpHost httpProxy, String u
5556
throw new WxErrorException(WxError.fromJson(responseContent));
5657
}
5758
}
58-
InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response);
59-
6059
return FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), "jpg");
6160
} finally {
6261
httpGet.releaseConnection();

0 commit comments

Comments
 (0)