Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8345807

InheritableThreadLocal holds stale value when working with ThreadPool

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      The value in InheritableThreadLocal didn't get cleared if working with the ThreadPool getting via Executors.newCachedThreadPool()

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Please note it is a remittance issue, not reproducible every time.

      1. create Threadpool via Executors.newCachedThreadPool()
      2. init InheritableThreadLocal in a thread
      3. call InheritableThreadLocal.remove() in finally block
      3. read InheritableThreadLocal in another thread
      4. the step #3 returned stale value assigned in step #2

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The InheritableThreadLocal should clear the value
      ACTUAL -
      The InheritableThreadLocal still holds the stale value

      FREQUENCY : rarely


            tongwan Andrew Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: