mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-06-28 13:16:19 +08:00
🎨 【微信支付】修复连接池关闭异常问题
This commit is contained in:
parent
a051587d3e
commit
c91a5a8e22
@ -105,8 +105,8 @@ public class WxPayServiceApacheHttpImpl extends BaseWxPayServiceImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String requestV3(String url, String requestStr, HttpRequestBase httpRequestBase) throws WxPayException {
|
private String requestV3(String url, String requestStr, HttpRequestBase httpRequestBase) throws WxPayException {
|
||||||
try (CloseableHttpClient httpClient = this.createApiV3HttpClient();
|
CloseableHttpClient httpClient = this.createApiV3HttpClient();
|
||||||
CloseableHttpResponse response = httpClient.execute(httpRequestBase)) {
|
try (CloseableHttpResponse response = httpClient.execute(httpRequestBase)) {
|
||||||
//v3已经改为通过状态码判断200 204 成功
|
//v3已经改为通过状态码判断200 204 成功
|
||||||
int statusCode = response.getStatusLine().getStatusCode();
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
//post方法有可能会没有返回值的情况
|
//post方法有可能会没有返回值的情况
|
||||||
@ -142,8 +142,8 @@ public class WxPayServiceApacheHttpImpl extends BaseWxPayServiceImpl {
|
|||||||
public String postV3WithWechatpaySerial(String url, String requestStr) throws WxPayException {
|
public String postV3WithWechatpaySerial(String url, String requestStr) throws WxPayException {
|
||||||
HttpPost httpPost = this.createHttpPost(url, requestStr);
|
HttpPost httpPost = this.createHttpPost(url, requestStr);
|
||||||
this.configureRequest(httpPost);
|
this.configureRequest(httpPost);
|
||||||
try (CloseableHttpClient httpClient = this.createApiV3HttpClient();
|
CloseableHttpClient httpClient = this.createApiV3HttpClient();
|
||||||
CloseableHttpResponse response = httpClient.execute(httpPost)) {
|
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
|
||||||
//v3已经改为通过状态码判断200 204 成功
|
//v3已经改为通过状态码判断200 204 成功
|
||||||
int statusCode = response.getStatusLine().getStatusCode();
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
String responseString = "{}";
|
String responseString = "{}";
|
||||||
@ -178,9 +178,8 @@ public class WxPayServiceApacheHttpImpl extends BaseWxPayServiceImpl {
|
|||||||
@Override
|
@Override
|
||||||
public String requestV3(String url, HttpRequestBase httpRequest) throws WxPayException {
|
public String requestV3(String url, HttpRequestBase httpRequest) throws WxPayException {
|
||||||
this.configureRequest(httpRequest);
|
this.configureRequest(httpRequest);
|
||||||
|
CloseableHttpClient httpClient = this.createApiV3HttpClient();
|
||||||
try (CloseableHttpClient httpClient = this.createApiV3HttpClient();
|
try (CloseableHttpResponse response = httpClient.execute(httpRequest)) {
|
||||||
CloseableHttpResponse response = httpClient.execute(httpRequest)) {
|
|
||||||
//v3已经改为通过状态码判断200 204 成功
|
//v3已经改为通过状态码判断200 204 成功
|
||||||
int statusCode = response.getStatusLine().getStatusCode();
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
//post方法有可能会没有返回值的情况
|
//post方法有可能会没有返回值的情况
|
||||||
@ -223,11 +222,9 @@ public class WxPayServiceApacheHttpImpl extends BaseWxPayServiceImpl {
|
|||||||
@Override
|
@Override
|
||||||
public InputStream downloadV3(String url) throws WxPayException {
|
public InputStream downloadV3(String url) throws WxPayException {
|
||||||
HttpGet httpGet = new WxPayV3DownloadHttpGet(url);
|
HttpGet httpGet = new WxPayV3DownloadHttpGet(url);
|
||||||
httpGet.addHeader(ACCEPT, ContentType.WILDCARD.getMimeType());
|
this.configureRequest(httpGet);
|
||||||
String serialNumber = getWechatPaySerial(getConfig());
|
CloseableHttpClient httpClient = this.createApiV3HttpClient();
|
||||||
httpGet.addHeader(WECHAT_PAY_SERIAL, serialNumber);
|
try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
|
||||||
try (CloseableHttpClient httpClient = this.createApiV3HttpClient();
|
|
||||||
CloseableHttpResponse response = httpClient.execute(httpGet)) {
|
|
||||||
//v3已经改为通过状态码判断200 204 成功
|
//v3已经改为通过状态码判断200 204 成功
|
||||||
int statusCode = response.getStatusLine().getStatusCode();
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
Header contentType = response.getFirstHeader(HttpHeaders.CONTENT_TYPE);
|
Header contentType = response.getFirstHeader(HttpHeaders.CONTENT_TYPE);
|
||||||
|
Loading…
Reference in New Issue
Block a user