- 错别字
[图片] https://pay.weixin.qq.com/wiki/doc/api/deposit_sl.php?chapter=27_5&index=6
2020-10-22 - 官网提供的javaSDK与DEMO中的HttpClient是否会引起fullgc
HttpClient httpClient = HttpClientBuilder.create() .setConnectionManager(connManager) .build(); String url = "https://" + domain + urlSuffix; HttpPost httpPost = new HttpPost(url); RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(readTimeoutMs).setConnectTimeout(connectTimeoutMs).build(); httpPost.setConfig(requestConfig); StringEntity postEntity = new StringEntity(data, "UTF-8"); httpPost.addHeader("Content-Type", "text/xml"); httpPost.addHeader("User-Agent", USER_AGENT + " " + config.getMchID()); httpPost.setEntity(postEntity); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); return EntityUtils.toString(httpEntity, "UTF-8");为什么HttpClient最后没有关闭,而且每次request都会创建一个HttpClient对象(是否需要使用CloseableHttpClient),创建HttpClient是一个很耗费资源的过程,这样在高并发下会不会出现fullgc,如果来不及回收的情况下,系统直接挂掉 官网demo下载地址:https://pay.weixin.qq.com/wiki/doc/api/micropay_sl.php?chapter=11_1
2019-04-28