Skip to content

Commit 9ba4b47

Browse files
committed
Defensive processing of timeout callback and timeout result
Issue: SPR-14978
1 parent 9376748 commit 9ba4b47

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,24 @@ final DeferredResultProcessingInterceptor getInterceptor() {
253253
return new DeferredResultProcessingInterceptorAdapter() {
254254
@Override
255255
public <S> boolean handleTimeout(NativeWebRequest request, DeferredResult<S> deferredResult) {
256-
if (timeoutCallback != null) {
257-
timeoutCallback.run();
256+
boolean continueProcessing = true;
257+
try {
258+
if (timeoutCallback != null) {
259+
timeoutCallback.run();
260+
}
258261
}
259-
if (timeoutResult != RESULT_NONE) {
260-
setResultInternal(timeoutResult);
262+
finally {
263+
if (timeoutResult != RESULT_NONE) {
264+
continueProcessing = false;
265+
try {
266+
setResultInternal(timeoutResult);
267+
}
268+
catch (Throwable ex) {
269+
logger.debug("Failed to handle timeout result", ex);
270+
}
271+
}
261272
}
262-
return true;
273+
return continueProcessing;
263274
}
264275
@Override
265276
public <S> void afterCompletion(NativeWebRequest request, DeferredResult<S> deferredResult) {

0 commit comments

Comments
 (0)