spring-framework / org.springframework.web.context.request.async / TimeoutCallableProcessingInterceptor

TimeoutCallableProcessingInterceptor

open class TimeoutCallableProcessingInterceptor : CallableProcessingInterceptor

Sends a 503 (SERVICE_UNAVAILABLE) in case of a timeout if the response is not already committed. As of 4.2.8 this is done indirectly by setting the result to an AsyncRequestTimeoutException which is then handled by Spring MVC's default exception handling as a 503 error.

Registered at the end, after all other interceptors and therefore invoked only if no other interceptor handles the timeout.

Note that according to RFC 7231, a 503 without a 'Retry-After' header is interpreted as a 500 error and the client should not retry. Applications can install their own interceptor to handle a timeout and add a 'Retry-After' header if necessary.

Author
Rossen Stoyanchev

Since
3.2

Constructors

<init>

TimeoutCallableProcessingInterceptor()

Sends a 503 (SERVICE_UNAVAILABLE) in case of a timeout if the response is not already committed. As of 4.2.8 this is done indirectly by setting the result to an AsyncRequestTimeoutException which is then handled by Spring MVC's default exception handling as a 503 error.

Registered at the end, after all other interceptors and therefore invoked only if no other interceptor handles the timeout.

Note that according to RFC 7231, a 503 without a 'Retry-After' header is interpreted as a 500 error and the client should not retry. Applications can install their own interceptor to handle a timeout and add a 'Retry-After' header if necessary.

Functions

handleTimeout

open fun <T : Any> handleTimeout(request: NativeWebRequest, task: Callable<T>): Any