2015-10-28 23:03 GMT+03:00 Milo van der Zee <m...@vanderzee.org>:
> Hello Chris,
>
> That is what I did but I expect a lot of people to have this problem. Seeing
> a lot of default valves included I would like to also have this valve as
> default.
>
> public class RequestValve extends ValveBase {
>     /**
>      * Session for current thread.
>      */
>     static InheritableThreadLocal<Request> requestHolder = new
> InheritableThreadLocal<>();
The "inheritable" above means that your "requestHolder.remove();" does
not remove all references.

Accessing request outside of request processing cycle would lead to
serious problems.

>     @Override
>     public void invoke(Request request, Response response) throws
> IOException, ServletException {
>         requestHolder.set(request);
>         try {
>             getNext().invoke(request, response);
>         } finally {
>             requestHolder.remove();
>         }
>     }
>
>     public static Request getRequest() {
>         return requestHolder.get();
>     }
> }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to