sratz commented on PR #552:
URL: 
https://github.com/apache/httpcomponents-client/pull/552#issuecomment-2622456032

   This change is incompatible.
   
   Consider when a *consumer* sets the attributes on the context:
   
   ```java
   BasicCookieStore cookieStore = new BasicCookieStore();
   HttpClientContext context = new HttpClientContext();
   context.setAttribute(HttpClientContext.COOKIE_STORE, cookieStore); // <----
   CloseableHttpClient client = HttpClients.createDefault();
   client.execute(new HttpGet("https://httpbin.org/cookies/set/foo/bar";), 
context, response -> null);
   System.out.println(cookieStore.getCookies());
   ```
   
   httpclient < 5.4 correctly uses the request-specific cookie store and prints:
   ```[[name: foo; value: bar; domain: httpbin.org; path: /; expiry: null]]```
   
   httpclient 5.4 does not care about the attribute anymore 
([diff](https://github.com/apache/httpcomponents-client/pull/552/files#diff-16278c1c7854154453531a554fbcaf624a76d7b6ca1e95eb529148f361fd9348R179-R180))
 and prints:
   ```[]```
   
   Switching from
   ```
   context.setAttribute(HttpClientContext.COOKIE_STORE, cookieStore);
   ```
   to
   ```
   context.setCookieStore(cookieStore);
   ```
   does not solve the problem, as that would work in 5.4, but not in 5.3 
anymore.
   
   The only chance I see to support both is to do *both*
   ```
   context.setAttribute(HttpClientContext.COOKIE_STORE, cookieStore);
   context.setCookieStore(cookieStore);
   ```
   
   Shouldn't this have been compatible? I.e. 
([here](https://github.com/apache/httpcomponents-client/pull/552/files#diff-16278c1c7854154453531a554fbcaf624a76d7b6ca1e95eb529148f361fd9348R179-R180)),
 consider *both* the getter and the attribute?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to