Intercepts concurrent request handling, where the concurrent result is
obtained by executing a Callable on behalf of the application with
A CallableProcessingInterceptor is invoked before and after the
invocation of the Callable task in the asynchronous thread, as well
as on timeout/error from a container thread, or after completing for any reason
including a timeout or network error.
As a general rule exceptions raised by interceptor methods will cause
async processing to resume by dispatching back to the container and using
the Exception instance as the concurrent result. Such exceptions will then
be processed through the HandlerExceptionResolver mechanism.
The handleTimeout method
can select a value to be used to resume processing.
Invoked before the start of concurrent handling in the original
thread in which the Callable is submitted for concurrent handling.
This is useful for capturing the state of the current thread just prior to
invoking the Callable. Once the state is captured, it can then be
transferred to the new Thread in
preProcess(NativeWebRequest, Callable). Capturing the state of
Spring Security's SecurityContextHolder and migrating it to the new Thread
is a concrete example of where this is useful.
Invoked after the Callable has produced a result in the
async thread in which the Callable is executed. This method may
be invoked later than afterTimeout or afterCompletion
depending on when the Callable finishes processing.
The default implementation is empty.
request - the current request
task - the task for the current async request
concurrentResult - the result of concurrent processing, which could
be a Throwable if the Callable raised an exception
Invoked from a container thread when the async request times out before
the Callable task completes. Implementations may return a value,
including an Exception, to use instead of the value the
Callable did not return in time.
Invoked from a container thread when an error occurred while processing
the async request before the Callable task completes.
Implementations may return a value, including an Exception, to
use instead of the value the Callable did not return in time.