Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BD69B200C34 for ; Mon, 27 Feb 2017 08:58:22 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id BC0F3160B7A; Mon, 27 Feb 2017 07:58:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 10E17160B60 for ; Mon, 27 Feb 2017 08:58:21 +0100 (CET) Received: (qmail 30494 invoked by uid 500); 27 Feb 2017 07:58:21 -0000 Mailing-List: contact commits-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list commits@struts.apache.org Received: (qmail 30481 invoked by uid 99); 27 Feb 2017 07:58:20 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Feb 2017 07:58:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B8C9CDFDC2; Mon, 27 Feb 2017 07:58:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cnenning@apache.org To: commits@struts.apache.org Date: Mon, 27 Feb 2017 07:58:20 -0000 Message-Id: <86ef7d8aa87e42628539fb407ffe0890@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] struts git commit: [WW-4741] Do not force session creation on locale read operation archived-at: Mon, 27 Feb 2017 07:58:22 -0000 Repository: struts Updated Branches: refs/heads/master 38409e0e0 -> 26fa06b11 [WW-4741] Do not force session creation on locale read operation Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/78db281c Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/78db281c Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/78db281c Branch: refs/heads/master Commit: 78db281cd6f66d50b3a5f48e2b1dee596d0a2232 Parents: 9fcf2df Author: Yasser Zamani Authored: Fri Feb 24 18:18:53 2017 +0330 Committer: Yasser Zamani Committed: Fri Feb 24 18:18:53 2017 +0330 ---------------------------------------------------------------------- .../struts2/interceptor/I18nInterceptor.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/78db281c/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java ---------------------------------------------------------------------- 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 f86c5f8..9060d69 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java @@ -34,6 +34,8 @@ import org.apache.struts2.dispatcher.Parameter; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + import java.util.Locale; import java.util.Map; @@ -296,12 +298,16 @@ public class I18nInterceptor extends AbstractInterceptor { Map 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); + } } } }