Java 测试因http客户端连接池问题而挂起

Java 测试因http客户端连接池问题而挂起,java,connection-pooling,apache-httpclient-4.x,Java,Connection Pooling,Apache Httpclient 4.x,当我运行测试时,它们挂起在同一点上:当我尝试发送请求时。 我知道池中没有免费连接,但我不知道如何修复此问题。有什么想法吗? 代码: 从日志: 2017-08-10 12:24:13,787 DEBUG | main | org.apache.http.client.protocol.RequestAddCookies.process.123 | CookieSpec selected: default 2017-08-10 12:24:13,787 DEBUG | main | org.apa

当我运行测试时,它们挂起在同一点上:当我尝试发送请求时。 我知道池中没有免费连接,但我不知道如何修复此问题。有什么想法吗? 代码:

从日志:

2017-08-10 12:24:13,787 DEBUG | main | org.apache.http.client.protocol.RequestAddCookies.process.123 | CookieSpec selected: default 
2017-08-10 12:24:13,787 DEBUG | main | org.apache.http.client.protocol.RequestAddCookies.process.168 | Cookie [version: 0][name: JSESSIONID][value: 00000000000000000000000000000][domain: localhost][path: /][expiry: null] match [localhost:9900/path/to/my/resource] 
2017-08-10 12:24:13,787 DEBUG | main | org.apache.http.client.protocol.RequestAuthCache.process.77 | Auth cache not set in the context 
2017-08-10 12:24:13,787 DEBUG | main | org.apache.http.impl.conn.PoolingHttpClientConnectionManager.requestConnection.255 | Connection request: [route: {}->http://localhost:9900][total kept alive: 0; route allocated: 2 of 2; total allocated: 2 of 20] 
2017-08-10 12:24:33,919 DEBUG | HikariPool-1 housekeeper | com.zaxxer.hikari.pool.HikariPool.logPoolState.378 | HikariPool-1 - Pool stats (total=2, active=0, idle=2, waiting=0) 

首先,您必须关闭您的响应:

CloseableHttpResponse response = httpclient.execute(httpget);
try {
    <...>
} finally {
    response.close();
}

更新了代码。我正在检查响应代码。它只是一个URL。比如:
CloseableHttpResponse response = httpclient.execute(httpget);
try {
    <...>
} finally {
    response.close();
}
PoolingHttpClientConnectionManager cm = new 
PoolingHttpClientConnectionManager();
cm.setMaxTotal(200);
cm.setDefaultMaxPerRoute(20);
HttpHost localhost = new HttpHost("locahost", 80);
cm.setMaxPerRoute(new HttpRoute(localhost), 50);
CloseableHttpClient httpClient = HttpClients.custom()
    .setConnectionManager(cm)
    .build();