@Test public void testDoFilterInternal_occur_exception() throws ServletException, IOException { ServletException occurException = new ServletException("test"); doThrow(occurException).when(mockFilterChain).doFilter(mockRequest, mockResponse); MDC.put("key0", "value0"); try { testTarget.doFilterInternal(mockRequest, mockResponse, mockFilterChain); fail("don't occur ServletException."); } catch (ServletException e) { assertThat(e, is(occurException)); } assertThat(MDC.getCopyOfContextMap(), is(nullValue())); }
@Override protected final void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { try { filterChain.doFilter(request, response); } finally { MDC.clear(); } }
MDCClearFilter extends OncePerRequestFilter { @Override protected final void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { try { filterChain.doFilter(request, response); } finally { MDC.clear(); } } }
MDCClearFilter extends OncePerRequestFilter { @Override protected final void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { try { filterChain.doFilter(request, response); } finally { MDC.clear(); } }  }
MDCClearFilter extends OncePerRequestFilter { @Override protected final void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { try { filterChain.doFilter(request, response); } finally { MDC.clear(); } }   }
MDCClearFilter extends OncePerRequestFilter { @Override protected final void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { try { filterChain.doFilter(request, response); } finally { MDC.clear(); } }    }