Skip to content

Commit

Permalink
WW-4741 Merges #119 which avoids session creation on locale read oper…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
cnenning committed Feb 27, 2017
2 parents 38409e0 + 78db281 commit 26fa06b
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import java.util.Locale;
import java.util.Map;

Expand Down Expand Up @@ -296,12 +298,16 @@ public Locale read(ActionInvocation invocation) {
Map<String, Object> session = invocation.getInvocationContext().getSession();

if (session != null) {
String sessionId = ServletActionContext.getRequest().getSession().getId();
synchronized (sessionId.intern()) {
Object sessionLocale = session.get(attributeName);
if (sessionLocale != null && sessionLocale instanceof Locale) {
locale = (Locale) sessionLocale;
LOG.debug("Applied session locale: {}", locale);
//[WW-4741] Do not force session creation while this is a read operation
HttpSession httpSession = ServletActionContext.getRequest().getSession(false);
if(null != httpSession) {
String sessionId = httpSession.getId();
synchronized (sessionId.intern()) {
Object sessionLocale = session.get(attributeName);
if (sessionLocale != null && sessionLocale instanceof Locale) {
locale = (Locale) sessionLocale;
LOG.debug("Applied session locale: {}", locale);
}
}
}
}
Expand Down

0 comments on commit 26fa06b

Please sign in to comment.