Class TimeoutDeferredResultProcessingInterceptor
- java.lang.Object
- org.springframework.web.context.request.async.TimeoutDeferredResultProcessingInterceptor
- All Implemented Interfaces:
DeferredResultProcessingInterceptor
public class TimeoutDeferredResultProcessingInterceptor extends Object implements DeferredResultProcessingInterceptor
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 returningAsyncRequestTimeoutException
as the result of processing 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.
- Since:
- 3.2
- Author:
- Rossen Stoyanchev
Constructor Summary
Constructors Constructor Description TimeoutDeferredResultProcessingInterceptor()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> boolean
handleTimeout(NativeWebRequest request, DeferredResult<T> result)
Invoked from a container thread when an async request times out before theDeferredResult
has been set.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.web.context.request.async.DeferredResultProcessingInterceptor
afterCompletion, beforeConcurrentHandling, handleError, postProcess, preProcess
Constructor Detail
TimeoutDeferredResultProcessingInterceptor
public TimeoutDeferredResultProcessingInterceptor()
Method Detail
handleTimeout
public <T> boolean handleTimeout(NativeWebRequest request, DeferredResult<T> result) throws Exception
Description copied from interface:DeferredResultProcessingInterceptor
Invoked from a container thread when an async request times out before theDeferredResult
has been set. Implementations may invokesetResult
orsetErrorResult
to resume processing.- Specified by:
handleTimeout
in interfaceDeferredResultProcessingInterceptor
- Parameters:
request
- the current requestresult
- the DeferredResult for the current request; if theDeferredResult
is set, then concurrent processing is resumed and subsequent interceptors are not invoked- Returns:
true
if processing should continue, orfalse
if other interceptors should not be invoked- Throws:
Exception
- in case of errors