Commits

rainerh  committed 0c6e85c

WW-2507 I18nInterceptor's intercept method is not thread safe
o synchonized access to session

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

  • Participants
  • Parent commits 1b6a038

Comments (0)

Files changed (1)

File src/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java

 
         //save it in session
         Map session = invocation.getInvocationContext().getSession();
+
+
         if (session != null) {
-            if (requested_locale != null) {
-                Locale locale = (requested_locale instanceof Locale) ?
-                        (Locale) requested_locale : LocalizedTextUtil.localeFromString(requested_locale.toString(), null);
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("store locale=" + locale);
+            synchronized (session) {
+                if (requested_locale != null) {
+                    Locale locale = (requested_locale instanceof Locale) ?
+                            (Locale) requested_locale : LocalizedTextUtil.localeFromString(requested_locale.toString(), null);
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("store locale=" + locale);
+                    }
+
+                    if (locale != null) {
+                        session.put(attributeName, locale);
+                    }
                 }
 
-                if (locale != null) {
-                    session.put(attributeName, locale);
-                }
-            }
+                //set locale for action
+                Object locale = session.get(attributeName);
+                if (locale != null && locale instanceof Locale) {
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("apply locale=" + locale);
+                    }
 
-            //set locale for action
-            Object locale = session.get(attributeName);
-            if (locale != null && locale instanceof Locale) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("apply locale=" + locale);
+                    saveLocale(invocation, (Locale)locale);
                 }
-
-                saveLocale(invocation, (Locale)locale);
             }
         }