[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-1609?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14582425#comment-14582425
 ] 

Dmitry Potapov commented on HTTPCLIENT-1609:
--------------------------------------------

Just got a pretty bad shot in the foot with this fix.
{{BHttpConnectionBase.isStale()}} works much slower than simple {{return 
true;}} so, {{AbstractConnPool.getPoolEntryBlocking()}} main loop, which is 
performed under the lock, works a bit slower with this fix, which result in 
slower connection leasing after bursts of activity.
This fix is pretty good one. I just want everybody know about its side-effects. 
I hope I selected the best way for such notification.

BTW, all these side-effects can be neutralized with 
{{PoolingHttpClientConnectionManager.setValidateAfterInactivity(0);}}. Hope 
this will help anybody who also encountered such a problem.

> Implementation of validate() Required In CPool
> ----------------------------------------------
>
>                 Key: HTTPCLIENT-1609
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1609
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.4 Final
>            Reporter: Charles Lip
>              Labels: patch
>             Fix For: 4.4.1
>
>
> In httpclient-4.4, org.apache.http.impl.conn.CPool directly inherits the 
> dummy method validate() from abstract class 
> org.apache.http.pool.AbstractConnPool:-
> /** * @since 4.4 */
> protected boolean validate(final E entry)
> { return true; }
> Given that validate() always return TRUE, a critical portion of codes related 
> to "closing stale connection" in method AbstractConnPool 
> .getPoolEntryBlocking() is rendered unreachable.
> Snippet of codes showing the unreachable part of method AbstractConnPool 
> .getPoolEntryBlocking():
> ....
> else if (this.validateAfterInactivity > 0) {
>    if (entry.getUpdated() + this.validateAfterInactivity <=   
> System.currentTimeMillis()) {
>       if (!validate(entry)) {
>          entry.close(); //unreachable
>       }
>    }
> }
> ... ..
> PoolingHttpClientConnectionManager, which is supported by CPool, is impaired 
> by this defect for stale connection management logics involving 
> validateAfterInactivity property.
> CPool class needs a proper implementation of method validate(); a possible 
> fix would be:
> @Override
> protected boolean validate(final CPoolEntry entry) {
>  return !entry.getConnection().isStale();
> }



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to