增加设置setConnectionManagerShared参数避免PoolingHttpClientConnectionManager被CloseableHttpClient连带关闭

This commit is contained in:
ben
2016-09-14 16:39:37 +08:00
parent 6d3b065f32
commit 15f17b2a27

View File

@ -1,8 +1,6 @@
package me.chanjar.weixin.common.util.http;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import me.chanjar.weixin.common.util.StringUtils;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
@ -23,7 +21,8 @@ import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.protocol.HttpContext;
import me.chanjar.weixin.common.util.StringUtils;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
/**
* httpclient 连接管理器
@ -125,6 +124,7 @@ public class DefaultApacheHttpClientBuilder implements ApacheHttpClientBuilder {
this.httpClientBuilder = HttpClients.custom()
.setConnectionManager(connectionManager)
.setConnectionManagerShared(true)
.setDefaultRequestConfig(
RequestConfig.custom()
.setSocketTimeout(this.soTimeout)