tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: svn commit: r1022117 - in /tomcat/tc6.0.x/trunk: ./ STATUS.txt java/org/apache/catalina/core/ApplicationContext.java java/org/apache/catalina/core/StandardContext.java webapps/docs/changelog.xml
Date Thu, 14 Oct 2010 06:16:09 GMT
2010/10/14 sebb <sebbaz@gmail.com>:
> On 14 October 2010 00:05, Konstantin Kolinko <knst.kolinko@gmail.com> wrote:
>> Re: sebb:
>> 2010/10/13 sebb <sebbaz@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message