You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Musachy Barroso (JIRA)" <ji...@apache.org> on 2008/12/18 20:25:37 UTC

[jira] Resolved: (WW-2834) LocalizedTextUtil messageFormats cache is NOT thread safe

     [ https://issues.apache.org/struts/browse/WW-2834?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Musachy Barroso resolved WW-2834.
---------------------------------

    Resolution: Fixed

Fixed on xwork trunk already. messageFormats is now synchronized on that method.

> LocalizedTextUtil messageFormats cache is NOT thread safe
> ---------------------------------------------------------
>
>                 Key: WW-2834
>                 URL: https://issues.apache.org/struts/browse/WW-2834
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Interceptors
>    Affects Versions: 2.0.11.2
>            Reporter: Kirk Rasmussen
>            Priority: Critical
>             Fix For: 2.1.3
>
>
> Here is a snippet from com.opensymphony.xwork2.util.LocalizedTextUtil that illustrates one (could be more) problem. This could be easily fixed by using the JDK 1.5 ConcurrentHashMap collection instead. I guess technically this is an XWork problem but it is used by the default TextProvider implementation.
>     private static final Map messageFormats = new HashMap();
>     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);
>         }
>         return format;
>     }
> Also the MessageFormat class itself is not thread safe and must be syncronized.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.