File tree 1 file changed +9
-6
lines changed
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config
1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -279,15 +279,18 @@ public CloseableHttpClient initApiV3HttpClient() throws WxPayException {
279
279
if (StringUtils .isNotBlank (this .getPrivateKeyString ())) {
280
280
this .setPrivateKeyString (Base64 .getEncoder ().encodeToString (this .getPrivateKeyString ().getBytes ()));
281
281
}
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
+ }
285
287
286
288
}
287
289
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
+ }
291
294
this .certSerialNo = certificate .getSerialNumber ().toString (16 ).toUpperCase ();
292
295
}
293
296
You can’t perform that action at this time.
0 commit comments