org.springframework.web.filter

Class RequestContextFilter

    • Constructor Detail

      • RequestContextFilter

        public RequestContextFilter()
    • Method Detail

      • setThreadContextInheritable

        public void setThreadContextInheritable(boolean threadContextInheritable)
        Set whether to expose the LocaleContext and RequestAttributes as inheritable for child threads (using an InheritableThreadLocal).

        Default is "false", to avoid side effects on spawned background threads. Switch this to "true" to enable inheritance for custom child threads which are spawned during request processing and only used for this request (that is, ending after their initial task, without reuse of the thread).

        WARNING: Do not use inheritance for child threads if you are accessing a thread pool which is configured to potentially add new threads on demand (e.g. a JDK ThreadPoolExecutor), since this will expose the inherited context to such a pooled thread.

      • shouldNotFilterAsyncDispatch

        protected boolean shouldNotFilterAsyncDispatch()
        Returns "false" so that the filter may set up the request context in each asynchronously dispatched thread.
        Overrides:
        shouldNotFilterAsyncDispatch in class OncePerRequestFilter
      • shouldNotFilterErrorDispatch

        protected boolean shouldNotFilterErrorDispatch()
        Returns "false" so that the filter may set up the request context in an error dispatch.
        Overrides:
        shouldNotFilterErrorDispatch in class OncePerRequestFilter