Lubos Husivarga created HTTPCORE-712:
----------------------------------------
Summary: AsyncClientEndpoint is not released upon lease failure
Key: HTTPCORE-712
URL: https://issues.apache.org/jira/browse/HTTPCORE-712
Project: HttpComponents HttpCore
Issue Type: Bug
Components: HttpCore NIO
Affects Versions: 5.2-alpha1
Reporter: Lubos Husivarga
When I use AsyncHttpClient and try to lease an endpoint to host
"https://localhost", I receive javax.net.ssl.SSLHandshakeException exception
via callback's failed method. That's ok, because my localhost certificate is
not signed by authority.
The strange thing is that the endpoint is allocated from
PoolingAsyncClientConnectionManager, but not released after the connection
failure during the endpoint lease operation.
There is no way to release the endpoint from callback failed method, because
there is no reference to it.
Failing the lease multiple times consumes all available connections from
connection manager pool and any further lease operation remains in pending
state preventing any other connections to the host.
example:
{code:java}
httpManager = PoolingAsyncClientConnectionManagerBuilder.create()
.setDefaultConnectionConfig(ConnectionConfig.custom()
.setTimeToLive(TimeValue.NEG_ONE_MILLISECOND) //TTL is
maximum time one connection can be used,
//then it is closed and new one is opened. Therefore -1
disables TTL and same connection lasts until
//it is actively used. Then closed by
IdleConnectionEvictor thread.
.build())
.setDefaultTlsConfig(TlsConfig.custom()
.setVersionPolicy(HttpVersionPolicy.NEGOTIATE)
.build())
.build();
httpClient = HttpAsyncClients.createMinimal(
H2Config.DEFAULT,
Http1Config.DEFAULT,
IOReactorConfig.DEFAULT,
httpManager);
httpClient.start();
HttpHost host = new HttpHost("https", "localhost", 443);
httpClient.lease(host, new FutureCallback<AsyncClientEndpoint>() {
@Override
public void failed(Exception ex) {
}
@Override
public void completed(AsyncClientEndpoint result) {
}
@Override
public void cancelled() {
}
});
Set<HttpRoute> routes = httpManager.getRoutes();
List<RouteStats> stats = new ArrayList<RouteStats>(routes.size());
for(HttpRoute route : routes){
PoolStats s = httpManager.getStats(route);
System.out.println(route.getTargetHost().getHostName());
System.out.println(s.getAvailable());
System.out.println(s.getLeased());
System.out.println(s.getMax());
System.out.println(s.getPending());
}
{code}
--
This message was sent by Atlassian Jira
(v8.20.7#820007)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]