You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Oleg Kalnichevski (JIRA)" <ji...@apache.org> on 2018/10/24 07:54:00 UTC
[jira] [Resolved] (HTTPCORE-560) LaxConnPool adds wrong PoolEntry
to leased when processing pending requests
[ https://issues.apache.org/jira/browse/HTTPCORE-560?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Oleg Kalnichevski resolved HTTPCORE-560.
----------------------------------------
Resolution: Fixed
Fix Version/s: 5.0-beta6
[~desmondyeung] Many thanks for reporting this bug and contributing a fix.
Oleg
> LaxConnPool adds wrong PoolEntry to leased when processing pending requests
> ---------------------------------------------------------------------------
>
> Key: HTTPCORE-560
> URL: https://issues.apache.org/jira/browse/HTTPCORE-560
> Project: HttpComponents HttpCore
> Issue Type: Bug
> Components: HttpCore
> Affects Versions: 5.0-beta5
> Reporter: Desmond Yeung
> Priority: Major
> Fix For: 5.0-beta6
>
>
> I'm currently using HttpClient 5.0-beta1/HttpCore 5.0-beta2 and run into the following stacktrace fairly often in a production environment:
> {code:java}
> java.lang.IllegalStateException: Pool entry already present in the set of leased entries
> at org.apache.hc.core5.pool.LaxConnPool$PerRoutePool.addLeased(LaxConnPool.java:393)
> at org.apache.hc.core5.pool.LaxConnPool$PerRoutePool.lease(LaxConnPool.java:429)
> at org.apache.hc.core5.pool.LaxConnPool.lease(LaxConnPool.java:143)
> at org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager.lease(PoolingAsyncClientConnectionManager.java:216)
> at org.apache.hc.client5.http.impl.async.InternalHttpAsyncExecRuntime.acquireConnection(InternalHttpAsyncExecRuntime.java:89)
> at org.apache.hc.client5.http.impl.async.AsyncConnectExec.execute(AsyncConnectExec.java:152)
> at org.apache.hc.client5.http.impl.async.AsyncExecChainElement.execute(AsyncExecChainElement.java:54)
> at org.apache.hc.client5.http.impl.async.AsyncExecChainElement$1.proceed(AsyncExecChainElement.java:62)
> at org.apache.hc.client5.http.impl.async.AsyncProtocolExec.internalExecute(AsyncProtocolExec.java:170)
> at org.apache.hc.client5.http.impl.async.AsyncProtocolExec.execute(AsyncProtocolExec.java:133)
> at org.apache.hc.client5.http.impl.async.AsyncExecChainElement.execute(AsyncExecChainElement.java:54)
> at org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1.sendRequest(InternalAbstractHttpAsyncClient.java:170)
> at org.apache.hc.core5.http.nio.BasicRequestProducer.sendRequest(BasicRequestProducer.java:65)
> at org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient.execute(InternalAbstractHttpAsyncClient.java:144)
> at org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient.execute(CloseableHttpAsyncClient.java:78)
> {code}
> After doing some digging I believe that {{addLeased(releasedEntry);}} should be replaced with {{addLeased(availableEntry);}} in the following snippet of {{PerRoutePool#release}}. In it's current state, it appears that the polled {{leaseRequest}} gets leaked when this happens. Please let me know if my findings are correct.
>
> {code:java}
> while ((leaseRequest = pending.poll()) != null) {
> if (leaseRequest.isDone()) {
> continue;
> }
> final Object state = leaseRequest.getState();
> final Deadline deadline = leaseRequest.getDeadline();
> if (deadline.isExpired()) {
> leaseRequest.failed(DeadlineTimeoutException.from(deadline));
> } else {
> final PoolEntry<T, C> availableEntry = getAvailableEntry(state);
> if (availableEntry != null) {
> addLeased(releasedEntry);
> leaseRequest.completed(availableEntry);
> } else if (leased.size() < max) {
> final PoolEntry<T, C> newEntry = new PoolEntry<>(route, timeToLive);
> addLeased(newEntry);
> leaseRequest.completed(newEntry);
> }
> break;
> }
> }
> {code}
>
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org