From db596d23dea7a8f35b52581d92b00a18c3f45335 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 14 May 2013 17:01:46 -0400 Subject: [PATCH] Fix deadlock issue in DeferredResult Previously DeferredResult locked around the setting of the result including handling up to the part of submitting a dispatch. This can cause a deadlock if a timeout occurs at the same time since the Tomcat timeout thread has its own locking that permits only one thread to do timeout or dispatch processing. The fix reduces the locking to cover only the attempt to set the DeferredResult but not the dispatching. Issue: SPR-10485 --- .../web/context/request/async/DeferredResult.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java b/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java index 22ea83f4585..70e89d1bcea 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java @@ -173,9 +173,9 @@ public class DeferredResult { return false; } this.result = result; - if (this.resultHandler != null) { - this.resultHandler.handleResult(this.result); - } + } + if (this.resultHandler != null) { + this.resultHandler.handleResult(this.result); } return true; }