Uploaded image for project: 'Commons VFS'
  1. Commons VFS
  2. VFS-309

ThreadLocal memory leak in DefaultFileContent

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.1
    • Labels:
      None
    • Environment:

      Tomcat servlet container

      Description

      When using commons vfs in a servlet container the ThreadLocal values stored will not be released once the request finishes.

      There needs to be a method to clear these values otherwise the data will leak into the next request.

      This was detected with tomcat 6.0.26. Upon undeploying an app that uses commons vfs tomcat detects the leaks with a huge amount of the following messages:

      A web application created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@52fb241d]) and a value of type [org.apache.commons.vfs.provider.FileContentThreadData] (value [org.apache.commons.vfs.provider.FileContentThreadData@6600167a]) but failed to remove it when the web application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed.

        Attachments

        1. close-on-close_v02.patch
          10 kB
          Bernd Eckenfels
        2. threadlocal_setNull_vs_remove_bug.patch
          0.5 kB
          Ryan Boettcher

          Issue Links

            Activity

              People

              • Assignee:
                b.eckenfels Bernd Eckenfels
                Reporter:
                jontro jontro
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: