mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-03-13 21:33:41 +08:00
refactor: 优化RestTemplate在低版本引起的一个I/O异常
详细可参考:https://github.com/spring-projects/spring-framework/issues/21321
This commit is contained in:
@@ -48,4 +48,9 @@ public class WechatV2Client {
|
||||
public WechatMetaBean getWechatMetaBean() {
|
||||
return wechatMetaBean;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("hello 2021");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,8 +289,8 @@ public class SignatureProvider {
|
||||
cipher.init(Cipher.ENCRYPT_MODE, certificate.getPublicKey());
|
||||
|
||||
byte[] data = message.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] cipherdata = cipher.doFinal(data);
|
||||
return Base64Utils.encodeToString(cipherdata);
|
||||
byte[] cipherData = cipher.doFinal(data);
|
||||
return Base64Utils.encodeToString(cipherData);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new PayException(e);
|
||||
|
||||
@@ -26,6 +26,7 @@ import cn.felord.payment.wechat.v3.model.ResponseSignVerifyParams;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -336,6 +337,7 @@ public class WechatPayClient {
|
||||
*/
|
||||
private void applyDefaultRestTemplate() {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory());
|
||||
DefaultResponseErrorHandler errorHandler = new WechatPayResponseErrorHandler();
|
||||
restTemplate.setErrorHandler(errorHandler);
|
||||
List<HttpMessageConverter<?>> messageConverters = restTemplate.getMessageConverters();
|
||||
|
||||
Reference in New Issue
Block a user