Fix race condition in DateTimeOffsetPattern
authorChristopher Currens <ccurrens@microsoft.com>
Thu, 10 Dec 2015 23:55:26 +0000 (15:55 -0800)
committerChristopher Currens <ccurrens@microsoft.com>
Thu, 10 Dec 2015 23:55:26 +0000 (15:55 -0800)
src/mscorlib/src/System/Globalization/DateTimeFormatInfo.cs

index 440fff5..9ce02ea 100644 (file)
@@ -1244,7 +1244,7 @@ namespace System.Globalization {
             get {
                 if (dateTimeOffsetPattern == null) {
 
-                    dateTimeOffsetPattern = ShortDatePattern + " " + LongTimePattern;
+                    string dateTimePattern = ShortDatePattern + " " + LongTimePattern;
 
                     /* LongTimePattern might contain a "z" as part of the format string in which case we don't want to append a time zone offset */
 
@@ -1280,8 +1280,10 @@ namespace System.Globalization {
                     }
 
                     if (!foundZ) {
-                        dateTimeOffsetPattern = dateTimeOffsetPattern + " zzz";
-                    } 
+                        dateTimePattern = dateTimePattern + " zzz";
+                    }
+
+                    dateTimeOffsetPattern = dateTimePattern;
                 }
                 return (dateTimeOffsetPattern);
             }