Class MdcPopulatingFilter

All Implemented Interfaces:
jakarta.servlet.Filter, Aware, BeanNameAware, DisposableBean, InitializingBean, EnvironmentAware, EnvironmentCapable, ServletContextAware

@Component @Order(2) public class MdcPopulatingFilter extends OncePerRequestFilter
Populates MDC with authenticated user information for request-scoped logging context.
  • Constructor Details

    • MdcPopulatingFilter

      public MdcPopulatingFilter()
  • Method Details

    • doFilterInternal

      protected void doFilterInternal(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain filterChain) throws jakarta.servlet.ServletException, IOException
      Extracts authenticated user ID from security context and populates MDC for use in log messages. Runs after authentication is established but before business logic executes.
      Specified by:
      doFilterInternal in class OncePerRequestFilter
      Parameters:
      request - the HTTP request
      response - the HTTP response
      filterChain - the filter chain to continue processing
      Throws:
      jakarta.servlet.ServletException - if request processing fails
      IOException - if an I/O error occurs during filtering