hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: BasicHttpParams not thread-safe?
Date Sun, 01 Jun 2008 14:58:12 GMT
On Sun, 2008-06-01 at 15:29 +0100, sebb wrote:
> It looks like BasicHttpParams is not thread-safe.
> 
> Although it uses a HashMap (which is thread-safe) to store parameters,
> the instance variable which holds it is not final or volatile, and
> accesses to it are not synchronized.
> 
> If one thread calls setParameter() and creates the HashMap, there is
> no guarantee that another thread will see the HashMap.
> 
> One solution would be to always create the HashMap (in the ctor or in
> the variable defn).
> This would mean some internal changes - e.g. clear() - but are there
> any drawbacks to always creating the HashMap?
> 
> S///
> 

Sebastian,

It is performance trade-off. ´╗┐HttpParams are meant to be treated as
immutable once initialized. It is 'write once - read many' kind of
structure. So, we left ´╗┐BasicHttpParams uninitialized for performance
reasons, as they tend to be read from quite a lot. This just needs to be
documented properly (like so many other things. Oh well...)

Oleg



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


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


Mime
View raw message