Provide method to set async TimeoutHandler
Issue: SPR-9914
This commit is contained in:
@@ -66,6 +66,8 @@ public final class WebAsyncManager {
|
||||
|
||||
private AsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor(this.getClass().getSimpleName());
|
||||
|
||||
private Runnable timeoutHandler;
|
||||
|
||||
private Object concurrentResult = RESULT_NONE;
|
||||
|
||||
private Object[] concurrentResultContext;
|
||||
@@ -117,6 +119,15 @@ public final class WebAsyncManager {
|
||||
this.taskExecutor = taskExecutor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the handler to use when concurrent handling times out. If not set, by
|
||||
* default a timeout is handled by returning SERVICE_UNAVAILABLE (503).
|
||||
* @param timeoutHandler the handler
|
||||
*/
|
||||
public void setTimeoutHandler(Runnable timeoutHandler) {
|
||||
this.timeoutHandler = timeoutHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the selected handler for the current request chose to handle the
|
||||
* request asynchronously. A return value of "true" indicates concurrent
|
||||
@@ -348,6 +359,10 @@ public final class WebAsyncManager {
|
||||
Assert.state(this.asyncWebRequest != null, "AsyncWebRequest must not be null");
|
||||
this.asyncWebRequest.startAsync();
|
||||
|
||||
if (this.timeoutHandler != null) {
|
||||
this.asyncWebRequest.setTimeoutHandler(this.timeoutHandler);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
HttpServletRequest request = asyncWebRequest.getNativeRequest(HttpServletRequest.class);
|
||||
String requestUri = urlPathHelper.getRequestUri(request);
|
||||
|
||||
Reference in New Issue
Block a user