mirror of
https://github.com/apache/struts.git
synced 2026-08-06 07:06:58 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user