Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-4574

ThreadContext does not properly remove the ThreadLocal from the current thread

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 6.0.0-beta1
    • 1.5.8, 6.0.0-beta3
    • wicket
    • None

    Description

      Actually, I only checked 6.0.0-beta2 and master, 6.0.0-beta2 is not in the drop down.

      ThreadLocal.get() returns the current value, if one is set. If not, it creates a new value using the initialValue() method, AND (importantly) registers the ThreadLocal in the Thread's Map of ThreadLocals.

      In order for the get(false) method to work as expected, we must actually call ThreadLocal.remove() after a ThreadLocal.get() that returned null.

      Also, after the request was processed, we never properly remove the ThreadLocal from the Thread, we were simply setting it to the previous value, which was null most of the time. This is not enough. The ThreadLocal was still attached to the Thread, just the value it was storing was null.

      Here's hoping that Jira is working again and I can attach a patch.

      Attachments

        1. threadContext.patch
          2 kB
          Jesse Long

        Activity

          People

            mgrigorov Martin Tzvetanov Grigorov
            jesselong Jesse Long
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: