@Test public void testDoFilter_occur_error() throws IOException, ServletException { OutOfMemoryError occurError = new OutOfMemoryError("out of memory error."); doThrow(occurError).when(mockFilterChain).doFilter(mockRequest, mockResponse); try { testTarget.doFilter(mockRequest, mockResponse, mockFilterChain); } catch (OutOfMemoryError e) { assertSame(occurError, e); } verify(mockExceptionLogger, times(0)).error((Exception) any()); }
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { try { filterChain.doFilter(servletRequest, servletResponse); } catch (IOException e) { logIOException(e, servletRequest, servletResponse); throw e; } catch (ServletException e) { logServletException(e, servletRequest, servletResponse); throw e; } catch (RuntimeException e) { logRuntimeException(e, servletRequest, servletResponse); throw e; } }
ExceptionLoggingFilter extends GenericFilterBean { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { try { filterChain.doFilter(servletRequest, servletResponse); } catch (IOException e) { logIOException(e, servletRequest, servletResponse); throw e; } catch (ServletException e) { logServletException(e, servletRequest, servletResponse); throw e; } catch (RuntimeException e) { logRuntimeException(e, servletRequest, servletResponse); throw e; } } }
ExceptionLoggingFilter extends GenericFilterBean { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { try { filterChain.doFilter(servletRequest, servletResponse); } catch (IOException e) { logIOException(e, servletRequest, servletResponse); throw e; } catch (ServletException e) { logServletException(e, servletRequest, servletResponse); throw e; } catch (RuntimeException e) { logRuntimeException(e, servletRequest, servletResponse); throw e; } }  }
ExceptionLoggingFilter extends GenericFilterBean { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { try { filterChain.doFilter(servletRequest, servletResponse); } catch (IOException e) { logIOException(e, servletRequest, servletResponse); throw e; } catch (ServletException e) { logServletException(e, servletRequest, servletResponse); throw e; } catch (RuntimeException e) { logRuntimeException(e, servletRequest, servletResponse); throw e; } }  void setExceptionLogger(final ExceptionLogger exceptionLogger); @Override void doFilter(ServletRequest servletRequest,
            ServletResponse servletResponse,
            FilterChain filterChain); }
ExceptionLoggingFilter extends GenericFilterBean { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { try { filterChain.doFilter(servletRequest, servletResponse); } catch (IOException e) { logIOException(e, servletRequest, servletResponse); throw e; } catch (ServletException e) { logServletException(e, servletRequest, servletResponse); throw e; } catch (RuntimeException e) { logRuntimeException(e, servletRequest, servletResponse); throw e; } }  void setExceptionLogger(final ExceptionLogger exceptionLogger); @Override void doFilter(ServletRequest servletRequest,
            ServletResponse servletResponse,
            FilterChain filterChain);  }