Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4741

Http Sessions forcefully created for all requests using I18nInterceptor with default Storage value.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.10
    • Fix Version/s: 2.5.12
    • Component/s: None
    • Labels:
      None

      Description

      Changes made in WW-4730 for store and read functions cause an httpSession to be created for every request that uses I18nInterceptor when storage = Storage.SESSION.

      Current code checks for

      Map<String, Object> session = invocation.getInvocationContext().getSession()

      to be null and then calls

      ServletActionContext.getRequest().getSession()

      (notice how the second one references the HttpServletRequest. The HttpServletRequest Session and and the InvocationContext session are different. The request's session can be null, even if the InvocationContext's session is not).

      Calling .getSession() in this manner forcefully creates a session.

      An appropriate check here might be

      HttpSession httpSession = ServletActionContext.getRequest().getSession(false); 
      
      if(httpSession != null) {
      ... // get sessionId and synchronize on it
      }
      

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user yasserzamani opened a pull request:

          https://github.com/apache/struts/pull/119

          WW-4741 Do not force session creation on locale read operation

          These changes prevent Struts to create session for request when it tries to check if request's session has pre-putted locale. It returns null instead if the request has no valid HttpSession.

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/yasserzamani/struts WW-4741

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/struts/pull/119.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #119


          commit 78db281cd6f66d50b3a5f48e2b1dee596d0a2232
          Author: Yasser Zamani <yasser.zamani@live.com>
          Date: 2017-02-24T14:48:53Z

          WW-4741 Do not force session creation on locale read operation


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user yasserzamani opened a pull request: https://github.com/apache/struts/pull/119 WW-4741 Do not force session creation on locale read operation These changes prevent Struts to create session for request when it tries to check if request's session has pre-putted locale. It returns null instead if the request has no valid HttpSession. You can merge this pull request into a Git repository by running: $ git pull https://github.com/yasserzamani/struts WW-4741 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/struts/pull/119.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #119 commit 78db281cd6f66d50b3a5f48e2b1dee596d0a2232 Author: Yasser Zamani <yasser.zamani@live.com> Date: 2017-02-24T14:48:53Z WW-4741 Do not force session creation on locale read operation
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 78db281cd6f66d50b3a5f48e2b1dee596d0a2232 in struts's branch refs/heads/master from Yasser Zamani
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=78db281 ]

          WW-4741 Do not force session creation on locale read operation

          Show
          jira-bot ASF subversion and git services added a comment - Commit 78db281cd6f66d50b3a5f48e2b1dee596d0a2232 in struts's branch refs/heads/master from Yasser Zamani [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=78db281 ] WW-4741 Do not force session creation on locale read operation
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 26fa06b1174f48c862b081809cebb55c53df6f2e in struts's branch refs/heads/master from cnenning
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=26fa06b ]

          WW-4741 Merges #119 which avoids session creation on locale read operation

          Show
          jira-bot ASF subversion and git services added a comment - Commit 26fa06b1174f48c862b081809cebb55c53df6f2e in struts's branch refs/heads/master from cnenning [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=26fa06b ] WW-4741 Merges #119 which avoids session creation on locale read operation
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/struts/pull/119

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/struts/pull/119
          Hide
          cn42 Christoph Nenning added a comment -

          has been fixed by PR #119

          Show
          cn42 Christoph Nenning added a comment - has been fixed by PR #119
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build Struts-JDK7-master #597 (See https://builds.apache.org/job/Struts-JDK7-master/597/)
          WW-4741 Do not force session creation on locale read operation (yasser.zamani: rev 78db281cd6f66d50b3a5f48e2b1dee596d0a2232)

          • (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build Struts-JDK7-master #597 (See https://builds.apache.org/job/Struts-JDK7-master/597/ ) WW-4741 Do not force session creation on locale read operation (yasser.zamani: rev 78db281cd6f66d50b3a5f48e2b1dee596d0a2232) (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java

            People

            • Assignee:
              Unassigned
              Reporter:
              agreenfield Adam Greenfield
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development