Skip to content

Commit 93298fc

Browse files
icha024rstoyanchev
authored andcommitted
Catch RejectedExecutionException in WebAsyncManager
Issue: SPR-13836
1 parent 4818378 commit 93298fc

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

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

Lines changed: 25 additions & 18 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;
@@ -306,24 +307,30 @@ public void run() {
306307

307308
interceptorChain.applyBeforeConcurrentHandling(this.asyncWebRequest, callable);
308309
startAsyncProcessing(processingContext);
309-
310-
this.taskExecutor.submit(new Runnable() {
311-
@Override
312-
public void run() {
313-
Object result = null;
314-
try {
315-
interceptorChain.applyPreProcess(asyncWebRequest, callable);
316-
result = callable.call();
317-
}
318-
catch (Throwable ex) {
319-
result = ex;
320-
}
321-
finally {
322-
result = interceptorChain.applyPostProcess(asyncWebRequest, callable, result);
310+
try {
311+
this.taskExecutor.submit(new Runnable() {
312+
@Override
313+
public void run() {
314+
Object result = null;
315+
try {
316+
interceptorChain.applyPreProcess(asyncWebRequest, callable);
317+
result = callable.call();
318+
}
319+
catch (Throwable ex) {
320+
result = ex;
321+
}
322+
finally {
323+
result = interceptorChain.applyPostProcess(asyncWebRequest, callable, result);
324+
}
325+
setConcurrentResultAndDispatch(result);
323326
}
324-
setConcurrentResultAndDispatch(result);
325-
}
326-
});
327+
});
328+
}
329+
catch (RejectedExecutionException ex) {
330+
Object result = interceptorChain.applyPostProcess(this.asyncWebRequest, callable, ex);
331+
setConcurrentResultAndDispatch(result);
332+
throw ex;
333+
}
327334
}
328335

329336
private void setConcurrentResultAndDispatch(Object result) {

0 commit comments

Comments
 (0)