1. Click
  2. CLK-314

Context is cleared from ThreadLocal for forward calls


    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker 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.


        Henri Yandell made changes -
        Project Import Fri Mar 20 14:11:32 PDT 2009 [ 1237583492744 ]
        Malcolm Edgar made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Malcolm Edgar made changes -
        Fix Version/s 1.4 [ 10011 ]
        Status In Progress [ 3 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Malcolm Edgar made changes -
        Assignee Malcolm Edgar [ medgar ] Bob Schellink [ sabob ]
        Bob Schellink made changes -
        Attachment [ 10351 ]
        Bob Schellink made changes -
        Assignee Bob Schellink [ sabob ] Malcolm Edgar [ medgar ]
        Bob Schellink made changes -
        Attachment [ 10350 ]
        Bob Schellink made changes -
        Field Original Value New Value
        Status Open [ 1 ] In Progress [ 3 ]
        Bob Schellink created issue -


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


            • Created: