> From: [email protected] [mailto:[email protected]]
> 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/
- Chuck
P.S. The formatting looks a little odd here, with no space after an "if" nor
its opening parenthesis, but a space before the closing one. Also, the braces
on the case statements aren't needed; using them results in having two closing
braces in the same column at the end of the switch.
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you received
this in error, please contact the sender and delete the e-mail and its
attachments from all computers.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]