Uploaded image for project: 'MyFaces Trinidad'
  1. MyFaces Trinidad
  2. TRINIDAD-1273

Apply a request lifecuycle to ThreadLocals so that their contents don't leak across requests

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0.9-core, 1.2.9-core
    • 1.2.10-core
    • Archetype
    • None
    • All Web Servers that use thread pools and do not clean up ThreadLocals before returning the threads to the pool. This includes at least WLS and OC4J

    Description

      Trinidad and Trinidad customers use ThreadLocals to track per-request state in several instances. Typically, a ThreadLocal is used because the consuming code does not have access to the Request Object. Even though, the Request Object is available off of the ExternalContext, code that executes extremely early or late in the request lifecycle may not have access to a FacesContext.

      The proposed solution is to add a org.apache.myfaces.trinidad.util.ThreadLocalUtils class with a method:

      public static <T> ThreadLocal<T> newRequestThreadLocal()

      That will create a ThreadLocal instance that will be reset by the Trinidad implementation when the request finishes (using the same hook point that the Trinidad RequestContext uses to clean itself up). The trickiest part of the implementation is connecting the code that causes the removal of the ThreadLocals (which exists in the impl package) with the code that creates the ThreadLocals to be reset, which exists in the api package.

      Attachments

        1. JIRA_1273_1291.patch
          21 kB
          Blake Sullivan

        Activity

          People

            matzew Matthias Wessendorf
            btsulliv Blake Sullivan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 48h
                48h
                Remaining:
                Remaining Estimate - 48h
                48h
                Logged:
                Time Spent - Not Specified
                Not Specified