Uploaded image for project: 'Click'
  1. Click
  2. CLK-314

Context is cleared from ThreadLocal for forward calls



    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4
    • Component/s: core
    • Labels:
    • Environment:
      Click 1.4RC3


      Ricardo identified a serious bug in ClickServlet where we check if Context should be cleared from the ThreadLocal.

      Currently we check that if the forwarded request is of type ClickRequestWrapper, we do not clear the ThreadLocal, otherwise we do.

      I wrongly concluded that the forwarded request will always be the request passed into #requestDispatcher.forward(..).

      However the spec RequestDispatcher#forward states:

      "The request and response parameters must be either the same objects as were passed to the calling servlet's service method or be subclasses of the
      ServletRequestWrapper or ServletResponseWrapper classes that wrap them."

      meaning the request we pass to #forward might be wrapped by a subclass of ServletRequestWrapper. Jetty 5.12 does this by wrapping ClickRequestWrapper in a class called "DispatcherRequest".

      We can fix the problem by unwinding the request and look for an instance of ClickRequestWrapper.

      Unfortunately the above fix is not enough. After patching ClickServlet with the above fix, Jetty would not forward to the correct page. Instead it kept forwarding back to the original requests path.

      I think the problem is that ClickRequestWrapper references the original request instead of "DispatcherRequest". Will investigate further.




            • Assignee:
              sabob Bob Schellink
              sabob Bob Schellink
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: