2010/10/14 sebb <seb...@gmail.com>:
> On 14 October 2010 00:05, Konstantin Kolinko <knst.koli...@gmail.com> wrote:
>> Re: sebb:
>> 2010/10/13 sebb <seb...@gmail.com>:
>>>> -    private Map parameters = null;
>>>> +    private Map<String,String> parameters =
>>>> +        new ConcurrentHashMap<String,String>();
>>>
>>> This should be final, surely?
>>>
>>
>> There are a lot of non-final fields in ApplicationContext and I think
>> in related classes as well. I do not think making this specific one as
>> final is essential.  (Anyway, +1 if anybody wants to do that).
>
> Given that the fix is for thread-safety, using final is intended to
> ensure that the field is correctly published following construction.
> There's little point in using the thread-safe ConcurrentHashMap if the
> field is not identical in all threads...
>

The fix replaces creation on first access with creation at start time.
There are no races between threads when a servlet context starts. If
there were several threads, a sync between them should have been
elsewhere (to protect a lot of non-final fields that are being set
here).


Best regards,
Konstantin Kolinko

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

Reply via email to