Merge pull request #310 from aleksandr-m/feature/WW-4998_i18ninterceptor

WW-4998 I18nInterceptor's default storage should store locale
This commit is contained in:
Lukasz Lenart
2019-01-09 08:45:23 +01:00
committed by GitHub
2 changed files with 6 additions and 7 deletions
@@ -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;
@@ -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 {