You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by sebb <se...@gmail.com> on 2010/01/10 14:56:00 UTC

HashMap => ConcurrentHashMap in HttpClient

I'm working through the HashMap uses in HttpClient.

CookieSpecRegistry.getSpecNames() uses a LinkedHashMap and the test
TestCookiePolicy.testRegisterUnregisterCookieSpecFactory() currently
assumes that the names will be returned in registration order, though
the Javadoc is not clear on this.

Does the registration order really matter?
If not, then one can use ConcurrentHashMap and do away with synch.

I'm not sure if the following classes are intended to be used from
multiple threads.
If not, then there's little point using ConcurrentHashMap.

AuthSchemeBase and subclasses
AbstractCookieSpec and subclasses

ConnPoolByRoute is not threadsafe currently, but is always called with
a pool lock so using HashMap is OK.

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


Re: HashMap => ConcurrentHashMap in HttpClient

Posted by Oleg Kalnichevski <ol...@apache.org>.
sebb wrote:
> I'm working through the HashMap uses in HttpClient.
> 
> CookieSpecRegistry.getSpecNames() uses a LinkedHashMap and the test
> TestCookiePolicy.testRegisterUnregisterCookieSpecFactory() currently
> assumes that the names will be returned in registration order, though
> the Javadoc is not clear on this.
> 
> Does the registration order really matter?

I do not think it does.

> If not, then one can use ConcurrentHashMap and do away with synch.
> 
> I'm not sure if the following classes are intended to be used from
> multiple threads.
> If not, then there's little point using ConcurrentHashMap.
> 
> AuthSchemeBase and subclasses
> AbstractCookieSpec and subclasses
> 

AuthScheme and CookieSpec instances are not meant to be thread-safe. 
They are instantiated on a per request / execution thread basis.

Primarily we should fix AuthSchemeRegistry, CookieSpecRegistry and 
SchemeRegistry classes.

Oleg

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