Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-1609

Implementation of validate() Required In CPool

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.4 Final
    • 4.4.1
    • HttpClient (classic)

    Description

      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();
      }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              charleslip Charles Lip
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: