Skip to content

Commit 1ea9dd0

Browse files
icha024jhoeller
authored andcommitted
Catch RejectedExecutionException in WebAsyncManager
Issue: SPR-13836 (cherry picked from commit 29692fc)
1 parent 9d5b643 commit 1ea9dd0

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

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

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
2121
import java.util.List;
2222
import java.util.Map;
2323
import java.util.concurrent.Callable;
24+
import java.util.concurrent.RejectedExecutionException;
2425
import javax.servlet.http.HttpServletRequest;
2526

2627
import org.apache.commons.logging.Log;
@@ -303,23 +304,29 @@ public void run() {
303304

304305
interceptorChain.applyBeforeConcurrentHandling(this.asyncWebRequest, callable);
305306
startAsyncProcessing(processingContext);
306-
307-
this.taskExecutor.submit(new Runnable() {
308-
public void run() {
309-
Object result = null;
310-
try {
311-
interceptorChain.applyPreProcess(asyncWebRequest, callable);
312-
result = callable.call();
313-
}
314-
catch (Throwable ex) {
315-
result = ex;
316-
}
317-
finally {
318-
result = interceptorChain.applyPostProcess(asyncWebRequest, callable, result);
307+
try {
308+
this.taskExecutor.submit(new Runnable() {
309+
public void run() {
310+
Object result = null;
311+
try {
312+
interceptorChain.applyPreProcess(asyncWebRequest, callable);
313+
result = callable.call();
314+
}
315+
catch (Throwable ex) {
316+
result = ex;
317+
}
318+
finally {
319+
result = interceptorChain.applyPostProcess(asyncWebRequest, callable, result);
320+
}
321+
setConcurrentResultAndDispatch(result);
319322
}
320-
setConcurrentResultAndDispatch(result);
321-
}
322-
});
323+
});
324+
}
325+
catch (RejectedExecutionException ex) {
326+
Object result = interceptorChain.applyPostProcess(this.asyncWebRequest, callable, ex);
327+
setConcurrentResultAndDispatch(result);
328+
throw ex;
329+
}
323330
}
324331

325332
private void setConcurrentResultAndDispatch(Object result) {

0 commit comments

Comments
 (0)