From baffa9a68b2ff02cab3387ab0b53794a1e541c7e Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Fri, 2 Dec 2016 19:30:36 +0100 Subject: [PATCH] WW-4722 Checks proper scope for stored locale --- .../struts2/interceptor/I18nInterceptor.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 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 16ce51fe3..4d3bdf079 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java @@ -235,16 +235,21 @@ public class I18nInterceptor extends AbstractInterceptor { * @return the read locale */ protected Locale readStoredLocale(ActionInvocation invocation) { - Locale locale = readStoredLocalFromSession(invocation); - if (locale != null) { - LOG.debug("Found stored Locale {} in session, using it!", locale); - return locale; + Locale locale; + if (storage == Storage.COOKIE) { + locale = readStoredLocalFromSession(invocation); + if (locale != null) { + LOG.debug("Found stored Locale {} in session, using it!", locale); + return locale; + } } - Locale cookie = readStoredLocaleFromCookie(invocation); - if (cookie != null) { - LOG.debug("Found stored Locale {} in cookies, using it!", locale); - return cookie; + if (storage == Storage.SESSION) { + locale = readStoredLocaleFromCookie(invocation); + if (locale != null) { + LOG.debug("Found stored Locale {} in cookies, using it!", locale); + return locale; + } } LOG.debug("Neither locale was in session nor in cookies, searching current Invocation context");