@Test public void testInvoke_responseCode_499() throws Throwable { NullPointerException occurException = new NullPointerException("null pointer exception."); HttpServletResponse mockResponse = mock(HttpServletResponse.class); SystemExceptionResolver resolver = new SystemExceptionResolver(); when(mockMethodInvocation.proceed()).thenReturn("viewname"); when(mockMethodInvocation.getThis()).thenReturn(resolver); when(mockResponse.getStatus()).thenReturn(499); when(mockMethodInvocation.getArguments()).thenReturn(new Object[] { null, mockResponse, null, occurException }); testTarget.invoke(mockMethodInvocation); verify(mockExceptionLogger, times(1)).warn((Exception) any()); }
@Override public Object invoke(MethodInvocation invocation) throws Throwable { Object returnObj = invocation.proceed(); if (returnObj == null) { return returnObj; } Object targetObject = invocation.getThis(); if (!(targetObject instanceof HandlerExceptionResolver)) { if (logger.isWarnEnabled()) { logger.warn( "target object does not implement the HandlerExceptionResolver interface. target object is '{}'.", targetObject.getClass().getName()); } return returnObj; } Exception exception = (Exception) invocation.getArguments()[3]; if (isTargetException(exception)) { HttpServletRequest request = (HttpServletRequest) invocation .getArguments()[0]; HttpServletResponse response = (HttpServletResponse) invocation .getArguments()[1]; Object handler = invocation.getArguments()[2]; log(exception, request, response, handler); } return returnObj; }
HandlerExceptionResolverLoggingInterceptor implements
                                                        MethodInterceptor,
                                                        InitializingBean { @Override public Object invoke(MethodInvocation invocation) throws Throwable { Object returnObj = invocation.proceed(); if (returnObj == null) { return returnObj; } Object targetObject = invocation.getThis(); if (!(targetObject instanceof HandlerExceptionResolver)) { if (logger.isWarnEnabled()) { logger.warn( "target object does not implement the HandlerExceptionResolver interface. target object is '{}'.", targetObject.getClass().getName()); } return returnObj; } Exception exception = (Exception) invocation.getArguments()[3]; if (isTargetException(exception)) { HttpServletRequest request = (HttpServletRequest) invocation .getArguments()[0]; HttpServletResponse response = (HttpServletResponse) invocation .getArguments()[1]; Object handler = invocation.getArguments()[2]; log(exception, request, response, handler); } return returnObj; } }
HandlerExceptionResolverLoggingInterceptor implements
                                                        MethodInterceptor,
                                                        InitializingBean { @Override public Object invoke(MethodInvocation invocation) throws Throwable { Object returnObj = invocation.proceed(); if (returnObj == null) { return returnObj; } Object targetObject = invocation.getThis(); if (!(targetObject instanceof HandlerExceptionResolver)) { if (logger.isWarnEnabled()) { logger.warn( "target object does not implement the HandlerExceptionResolver interface. target object is '{}'.", targetObject.getClass().getName()); } return returnObj; } Exception exception = (Exception) invocation.getArguments()[3]; if (isTargetException(exception)) { HttpServletRequest request = (HttpServletRequest) invocation .getArguments()[0]; HttpServletResponse response = (HttpServletResponse) invocation .getArguments()[1]; Object handler = invocation.getArguments()[2]; log(exception, request, response, handler); } return returnObj; } HandlerExceptionResolverLoggingInterceptor(); }
HandlerExceptionResolverLoggingInterceptor implements
                                                        MethodInterceptor,
                                                        InitializingBean { @Override public Object invoke(MethodInvocation invocation) throws Throwable { Object returnObj = invocation.proceed(); if (returnObj == null) { return returnObj; } Object targetObject = invocation.getThis(); if (!(targetObject instanceof HandlerExceptionResolver)) { if (logger.isWarnEnabled()) { logger.warn( "target object does not implement the HandlerExceptionResolver interface. target object is '{}'.", targetObject.getClass().getName()); } return returnObj; } Exception exception = (Exception) invocation.getArguments()[3]; if (isTargetException(exception)) { HttpServletRequest request = (HttpServletRequest) invocation .getArguments()[0]; HttpServletResponse response = (HttpServletResponse) invocation .getArguments()[1]; Object handler = invocation.getArguments()[2]; log(exception, request, response, handler); } return returnObj; } HandlerExceptionResolverLoggingInterceptor(); void setExceptionLogger(ExceptionLogger exceptionLogger); void setIgnoreExceptions(
            Set<Class<? extends Exception>> ignoreExceptions); @Override Object invoke(MethodInvocation invocation); @Override void afterPropertiesSet(); }
HandlerExceptionResolverLoggingInterceptor implements
                                                        MethodInterceptor,
                                                        InitializingBean { @Override public Object invoke(MethodInvocation invocation) throws Throwable { Object returnObj = invocation.proceed(); if (returnObj == null) { return returnObj; } Object targetObject = invocation.getThis(); if (!(targetObject instanceof HandlerExceptionResolver)) { if (logger.isWarnEnabled()) { logger.warn( "target object does not implement the HandlerExceptionResolver interface. target object is '{}'.", targetObject.getClass().getName()); } return returnObj; } Exception exception = (Exception) invocation.getArguments()[3]; if (isTargetException(exception)) { HttpServletRequest request = (HttpServletRequest) invocation .getArguments()[0]; HttpServletResponse response = (HttpServletResponse) invocation .getArguments()[1]; Object handler = invocation.getArguments()[2]; log(exception, request, response, handler); } return returnObj; } HandlerExceptionResolverLoggingInterceptor(); void setExceptionLogger(ExceptionLogger exceptionLogger); void setIgnoreExceptions(
            Set<Class<? extends Exception>> ignoreExceptions); @Override Object invoke(MethodInvocation invocation); @Override void afterPropertiesSet();  }