Class TimeoutCallableProcessingInterceptor
java.lang.Object
org.springframework.web.context.request.async.TimeoutCallableProcessingInterceptor
- All Implemented Interfaces:
- CallableProcessingInterceptor
public class TimeoutCallableProcessingInterceptor
extends Object
implements 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.
- Since:
- 3.2
- Author:
- Rossen Stoyanchev
- 
Field SummaryFields inherited from interface org.springframework.web.context.request.async.CallableProcessingInterceptorRESPONSE_HANDLED, RESULT_NONE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescription<T> ObjecthandleTimeout(NativeWebRequest request, Callable<T> task) Invoked from a container thread when the async request times out before theCallabletask completes.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.web.context.request.async.CallableProcessingInterceptorafterCompletion, beforeConcurrentHandling, handleError, postProcess, preProcess
- 
Constructor Details- 
TimeoutCallableProcessingInterceptorpublic TimeoutCallableProcessingInterceptor()
 
- 
- 
Method Details- 
handleTimeoutDescription copied from interface:CallableProcessingInterceptorInvoked from a container thread when the async request times out before theCallabletask completes. Implementations may return a value, including anException, to use instead of the value theCallabledid not return in time.The default implementation always returns CallableProcessingInterceptor.RESULT_NONE.- Specified by:
- handleTimeoutin interface- CallableProcessingInterceptor
- Parameters:
- request- the current request
- task- the task for the current async request
- Returns:
- a concurrent result value; if the value is anything other than
 CallableProcessingInterceptor.RESULT_NONEorCallableProcessingInterceptor.RESPONSE_HANDLED, concurrent processing is resumed and subsequent interceptors are not invoked
- Throws:
- Exception- in case of errors
 
 
-