Simon F created HTTPCLIENT-2343:
-----------------------------------

             Summary: Regression in setting USER_TOKEN context attribute in 
PoolingHttpClientConnectionManager
                 Key: HTTPCLIENT-2343
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2343
             Project: HttpComponents HttpClient
          Issue Type: Bug
          Components: HttpClient (classic)
    Affects Versions: 5.4-beta1
            Reporter: Simon F
         Attachments: Reproducer.java

Setting the USER_TOKEN context attribute changed between the 5.3.1 and 5.4 
release.

I’ve got a testcase where my application calls an https-endpoint five times and 
checks that the source port used by the clients stays the same (the existing 
connection is reused).

Using the httpclient v5.3.1 everything works fine, all requests use the same 
source port, but after upgrading to v5.4 my testcase fails.

I’ve tracked down the issue to the USER_TOKEN, which we set explicitly on the 
Context to reuse ssl connections even when client certificates are used.

Due to performance reasons this is essential to us.

We’ve set the Context like this:

{code}
HttpContext ctx = new HttpClientContext();
ctx.setAttribute(HttpClientContext.{_}USER_TOKEN{_}, "localhost:8443");
{code}

But as seen in the logs, the USER_TOKEN is no longer added to the state:

[ForkJoinPool-1-worker-1] DEBUG 
o.a.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ex-0000000001 
endpoint lease request (3 MINUTES) [route: 
\{s}->[https://localhost:65181]][total available: 0; route allocated: 0 of 10; 
total allocated: 0 of 50]

After changing the way we set the USER_TOKEN, it works again:
{code}
HttpClientContext ctx = new HttpClientContext();
ctx.setUserToken(location);
{code}

[ForkJoinPool-1-worker-1] DEBUG 
o.a.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ex-0000000001 
endpoint lease request (3 MINUTES) [route: 
\{s}->[https://localhost:65384]][state: ServiceLocation(hostname=localhost, 
port=65384, ssl=true)][total available: 0; route allocated: 0 of 10; total 
allocated: 0 of 50]

The USER_TOKEN was marked as deprecated in v5.4, but it should still work 
without modification.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to