struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amashche...@apache.org
Subject [struts] branch master updated: WW-4998 I18nInterceptor's default storage should store locale
Date Wed, 09 Jan 2019 20:34:37 GMT
This is an automated email from the ASF dual-hosted git repository.

amashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/struts.git


The following commit(s) were added to refs/heads/master by this push:
     new b315b6e  WW-4998 I18nInterceptor's default storage should store locale
b315b6e is described below

commit b315b6e5fdbd5cae6877cf87d232956fca12a899
Author: Aleksandr Mashchenko <amashchenko@apache.org>
AuthorDate: Mon Jan 7 17:29:46 2019 +0200

    WW-4998 I18nInterceptor's default storage should store locale
---
 .../java/org/apache/struts2/interceptor/I18nInterceptor.java     | 9 ++++-----
 .../java/org/apache/struts2/interceptor/I18nInterceptorTest.java | 4 ++--
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
index 682bbe6..4ddcedf 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
@@ -261,6 +261,7 @@ public class I18nInterceptor extends AbstractInterceptor {
             super(invocation);
         }
 
+        @Override
         public Locale find() {
             Locale requestOnlyLocale = super.find();
 
@@ -281,15 +282,13 @@ public class I18nInterceptor extends AbstractInterceptor {
 
         @Override
         public Locale store(ActionInvocation invocation, Locale locale) {
-            HttpSession session = ServletActionContext.getRequest().getSession(false);
+            Map<String, Object> session = invocation.getInvocationContext().getSession();
 
             if (session != null) {
-                String sessionId = session.getId();
+                String sessionId = ServletActionContext.getRequest().getSession().getId();
                 synchronized (sessionId.intern()) {
-                    invocation.getInvocationContext().getSession().put(attributeName, locale);
+                    session.put(attributeName, locale);
                 }
-            } else {
-                LOG.debug("session creation avoided as it doesn't exist already");
             }
 
             return locale;
diff --git a/core/src/test/java/org/apache/struts2/interceptor/I18nInterceptorTest.java b/core/src/test/java/org/apache/struts2/interceptor/I18nInterceptorTest.java
index fcc0dd1..da5607f 100644
--- a/core/src/test/java/org/apache/struts2/interceptor/I18nInterceptorTest.java
+++ b/core/src/test/java/org/apache/struts2/interceptor/I18nInterceptorTest.java
@@ -79,8 +79,8 @@ public class I18nInterceptorTest extends TestCase {
 
         assertFalse("should have been removed",
                 mai.getInvocationContext().getParameters().get(I18nInterceptor.DEFAULT_PARAMETER).isDefined());
-        assertNull("should not be created", request.getSession(false));
-        assertNull("should not be stored here", session.get(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE));
+        assertNotNull("should be created", request.getSession(false));
+        assertNotNull("should be stored here", session.get(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE));
     }
 
     public void testDefaultLocale() throws Exception {


Mime
View raw message