Commits

Anonymous committed 2c17dcf

Fix unsynchronized map

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1618e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (1)

src/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java

 
     private static MessageFormat buildMessageFormat(String pattern, Locale locale) {
         MessageFormatKey key = new MessageFormatKey(pattern, locale);
-        MessageFormat format = (MessageFormat) messageFormats.get(key);
-        if (format == null) {
-            format = new MessageFormat(pattern);
-            format.setLocale(locale);
-            format.applyPattern(pattern);
-            messageFormats.put(key, format);
+        MessageFormat format = null;
+        synchronized(messageFormats) {
+            format = (MessageFormat) messageFormats.get(key);
+            if (format == null) {
+                format = new MessageFormat(pattern);
+                format.setLocale(locale);
+                format.applyPattern(pattern);
+                messageFormats.put(key, format);
+            }
         }
 
         return format;