Browse Source

Catch RejectedExecutionException in WebAsyncManager

Issue: SPR-13836
pull/966/head
Ian Chan 10 years ago committed by Rossen Stoyanchev
parent
commit
29692fcc21
  1. 43
      spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java

43
spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,6 +21,7 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.RejectedExecutionException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -306,24 +307,30 @@ public final class WebAsyncManager {
interceptorChain.applyBeforeConcurrentHandling(this.asyncWebRequest, callable); interceptorChain.applyBeforeConcurrentHandling(this.asyncWebRequest, callable);
startAsyncProcessing(processingContext); startAsyncProcessing(processingContext);
try {
this.taskExecutor.submit(new Runnable() { this.taskExecutor.submit(new Runnable() {
@Override @Override
public void run() { public void run() {
Object result = null; Object result = null;
try { try {
interceptorChain.applyPreProcess(asyncWebRequest, callable); interceptorChain.applyPreProcess(asyncWebRequest, callable);
result = callable.call(); result = callable.call();
} }
catch (Throwable ex) { catch (Throwable ex) {
result = ex; result = ex;
} }
finally { finally {
result = interceptorChain.applyPostProcess(asyncWebRequest, callable, result); result = interceptorChain.applyPostProcess(asyncWebRequest, callable, result);
}
setConcurrentResultAndDispatch(result);
} }
setConcurrentResultAndDispatch(result); });
} }
}); catch (RejectedExecutionException ex) {
Object result = interceptorChain.applyPostProcess(this.asyncWebRequest, callable, ex);
setConcurrentResultAndDispatch(result);
throw ex;
}
} }
private void setConcurrentResultAndDispatch(Object result) { private void setConcurrentResultAndDispatch(Object result) {

Loading…
Cancel
Save