Uploaded image for project: 'Crowd Data Center'
  1. Crowd Data Center
  2. CWD-4096

RestCrowdClient http.max.connections doesn't take effect when the base URL doesn't include a port

    • Icon: Bug Bug
    • Resolution: Deployed
    • Icon: Medium Medium
    • 2.8.2
    • 2.8
    • None
    • None

      In OnDemand, the Crowd Base URL is configured as http://localhost/crowd/service/

      During RestExecutor initialisation the maximum connections per route is configured for the route "http://localhost" to be 20. There's a subtle problem with this though. When actually issuing a request to Horde, the HttpRoute becomes "http://localhost:80", which is treated differently, and falls back to the default maximum connections per route of 2.

      It looks like INST-2 introduced this issue, when they updated the Icebat to explicitly hack the CROWD_SERVER_BASE_URL in each services run file. /cc cchauvet

      Ultimately this looks like it might actually be an Apache HttpClient bug. In debugging I noticed that the outbound request is definitely "http://localhost/crowd/foo", but after it passes through all the various HttpClient "*Exec" steps it ends up as "http://localhost:80/crowd/foo".

            [CWD-4096] RestCrowdClient http.max.connections doesn't take effect when the base URL doesn't include a port

            Per request from jwalton, the patch will be applied under a new issue: CWD-4337

            Pierre-Etienne Poirot (Inactive) added a comment - Per request from jwalton , the patch will be applied under a new issue: CWD-4337

            Pierre-Etienne Poirot (Inactive) added a comment - This is still reproducible in Crowd 2.8.2 for https URLs: https://jira.atlassian.com/browse/STASH-7081?focusedCommentId=729448&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-729448

            \0/ thanks jwalton!

            Samuel Day (Inactive) added a comment - \0/ thanks jwalton !

            joe added a comment -

            HTTPCLIENT-1575, fixed upstream, will normalise HttpRoute instances to include a specific port (for now) and throw an IllegalArgumentException (in 5.0). The existing fix in Crowd (filling in the port in RestExecutor.routeFor) will continue to work with both implementations.

            joe added a comment - HTTPCLIENT-1575 , fixed upstream, will normalise HttpRoute instances to include a specific port (for now) and throw an IllegalArgumentException (in 5.0). The existing fix in Crowd (filling in the port in RestExecutor.routeFor ) will continue to work with both implementations.

            joe added a comment -

            It would be very easy to apply this workaround in code and always pass in an HttpRoute with the port resolved against DefaultSchemePortResolver.INSTANCE. But yes, this looks like a bug in HttpClient, or at least an underspecification of what PoolingHttpClientConnectionManager.setMaxPerRoute should do when passed an HttpRoute with port of -1.

            Good find!

            joe added a comment - It would be very easy to apply this workaround in code and always pass in an HttpRoute with the port resolved against DefaultSchemePortResolver.INSTANCE . But yes, this looks like a bug in HttpClient, or at least an underspecification of what PoolingHttpClientConnectionManager.setMaxPerRoute should do when passed an HttpRoute with port of -1. Good find!

            A workaround exists, explicitly set your base URL to http://localhost:80

            Samuel Day (Inactive) added a comment - A workaround exists, explicitly set your base URL to http://localhost:80

            That's correct.

            Samuel Day (Inactive) added a comment - That's correct.

            joe added a comment -

            To be clear on the cause and effect: if I create a RestExecutor with a base URL of http://localhost and a connections-per-route of twenty, I'll actually get a pool size of two?

            joe added a comment - To be clear on the cause and effect: if I create a RestExecutor with a base URL of http://localhost and a connections-per-route of twenty, I'll actually get a pool size of two?

            I think this is a bug in HttpClient itself. I'll raise something upstream.

            Samuel Day (Inactive) added a comment - I think this is a bug in HttpClient itself. I'll raise something upstream.

            joe added a comment -

            The URL used by a RestExecutor should be consistent. That is, it's constructed with a base URL and then all requests use the same one. If there's a base URL that doesn't behave like that, that would be a bug. And if there's a URL that pooling doesn't work with at all, that would also be a bug.

            Looks like you've already investigated here; can you see which case it is, or reduce this to a test of RestExecutor?

            joe added a comment - The URL used by a RestExecutor should be consistent. That is, it's constructed with a base URL and then all requests use the same one. If there's a base URL that doesn't behave like that, that would be a bug. And if there's a URL that pooling doesn't work with at all, that would also be a bug. Looks like you've already investigated here; can you see which case it is, or reduce this to a test of RestExecutor ?

              jwalton joe
              sday@atlassian.com Samuel Day (Inactive)
              Affected customers:
              0 This affects my team
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: