Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f6e300b

Browse filesBrowse files
committed
🎨 及时关闭打开的InputStream对象
1 parent 5a811ff commit f6e300b
Copy full SHA for f6e300b

File tree

Expand file treeCollapse file tree

1 file changed

+9
-6
lines changed
Filter options
  • weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config
Expand file treeCollapse file tree

1 file changed

+9
-6
lines changed

‎weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java

Copy file name to clipboardExpand all lines: weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java
+9-6Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,18 @@ public CloseableHttpClient initApiV3HttpClient() throws WxPayException {
279279
if (StringUtils.isNotBlank(this.getPrivateKeyString())) {
280280
this.setPrivateKeyString(Base64.getEncoder().encodeToString(this.getPrivateKeyString().getBytes()));
281281
}
282-
InputStream keyInputStream = this.loadConfigInputStream(this.getPrivateKeyString(), this.getPrivateKeyPath(),
283-
this.privateKeyContent, "privateKeyPath");
284-
merchantPrivateKey = PemUtils.loadPrivateKey(keyInputStream);
282+
283+
try (InputStream keyInputStream = this.loadConfigInputStream(this.getPrivateKeyString(), this.getPrivateKeyPath(),
284+
this.privateKeyContent, "privateKeyPath")) {
285+
merchantPrivateKey = PemUtils.loadPrivateKey(keyInputStream);
286+
}
285287

286288
}
287289
if (certificate == null && StringUtils.isBlank(this.getCertSerialNo())) {
288-
InputStream certInputStream = this.loadConfigInputStream(this.getPrivateCertString(), this.getPrivateCertPath(),
289-
this.privateCertContent, "privateCertPath");
290-
certificate = PemUtils.loadCertificate(certInputStream);
290+
try (InputStream certInputStream = this.loadConfigInputStream(this.getPrivateCertString(), this.getPrivateCertPath(),
291+
this.privateCertContent, "privateCertPath")) {
292+
certificate = PemUtils.loadCertificate(certInputStream);
293+
}
291294
this.certSerialNo = certificate.getSerialNumber().toString(16).toUpperCase();
292295
}
293296

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.