users@jersey.java.net

[Jersey] per user/thread cookie management

From: Russ Baker <rbaker_at_ghx.com>
Date: Tue, 9 Jul 2013 14:29:08 +0000

Hello Jersey Users,



We have implemented a performance enhancement by using only one HttpClient per application, and we are having issues with the cookie store. It seems as if each time we make a call, the cookie store is shared across calls instead of a new one used for each user/thread. This is causing us problems with our identity service because it thinks that the same user is making a call, when in fact it is another authenticated user.



From looking at the HttpComponents website - http://hc.apache.org/httpcomponents-client-ga/tutorial/html/statemgmt.html#d5e849 -it would appear that we need be able to access the "execute" method of the httpclient that specifies the cookie policy and provides a BasicCookieStore. In jersey-apache-client4-1.17.1, we are not able to do this as this is in the final class "ApacheHttpClient4Handler" and cannot override the class with our own implementation.



Besides using Javasisst to insert this code dynamically, is there a way that we can get the wrapped httpclient in the ApacheHttpClient4Handler to use a cookie jar on a per user/thread basis programatically or via configuration?


Russ Baker
Senior Software Engineer