Mark,

On 9/14/15 4:00 AM, Mark Thomas wrote:
> On 13/09/2015 23:11, Caldarale, Charles R wrote:
>>> From: ma...@apache.org [mailto:ma...@apache.org] 
>>> Subject: svn commit: r1702821 - in /tomcat/tc8.0.x/trunk: 
>>> java/org/apache/tomcat/util/http/HttpMessages.java 
>>> webapps/docs/changelog.xml
>>
>>> --- tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/http/HttpMessages.java 
>>> (original)
>>> +++ tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/http/HttpMessages.java 
>>> Sun Sep 13 20:36:40 2015
>>> @@ -69,26 +69,34 @@ public class HttpMessages {
>>>          // Does HTTP requires/allow international messages or
>>>          // are pre-defined? The user doesn't see them most of the time
>>>          switch( status ) {
>>> -        case 200:
>>> -            if(st_200 == null ) {
>>> -                st_200 = sm.getString("sc.200");
>>> +        case 200: {
>>> +            String s = st_200;
>>> +            if(s == null ) {
>>> +                st_200 = s = sm.getString("sc.200");
>>>              }
>>> -            return st_200;
>>
>> I'm not convinced this removes the data race, since there's still no 
>> guarantee that the storage writes that are part of the object initialization 
>> inside sm.getString() will be visible to another thread before the write to 
>> st_200. Shipilёv's blog has some interesting studies: 
>> http://shipilev.net/blog/2014/safe-public-construction/
> 
> OK. Let me have a read of that blog.
> 
> At the moment we have two people who claim to be expert in this area
> with different opinions on whether or not the above is safe. Personally,
> my money is on Chuck being right.

What's the reason for caching references to the return value of
sm.getString()? Is there a significant performance advantage?

-chris

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to