Spring MVC InterceptorHandler called twice with DeferredResult

The difference between the two invocations can be seen by examining the value of request.getDispatcherType().


You need to use org.springframework.web.servlet.AsyncHandlerInterceptor:

public interface AsyncHandlerInterceptor extends HandlerInterceptor {

    void afterConcurrentHandlingStarted(
            HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception;

}

Spring MVC execute sequence:

preHandle
afterConcurrentHandlingStarted
preHandle
postHandle
afterCompletion