-
Notifications
You must be signed in to change notification settings - Fork 38.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Concurrency problem in DeferredResult: potential double execution of handleResult [SPR-14978] #19544
Comments
Juergen Hoeller commented This looks like a side effect of the deadlock-avoiding fix for #15118: The code used to be the way you suggested it before but the overly strong lock for the I guess we need to find a looser way of enforcing a single |
yan.zhang commented thx. Sorry for my poor english. I still hava some confusion about it. It looks like the code in DeferredResult still will lead to a potential deadlock in Tomcat at present. !exm1.jpg|thumbnail! thread 1: (1)startAsyncProcessing (4)setResultHandler
thread 2: (3)DeferredResult.setResult
thread 3 (handle timeout): (2)handleTimeout (5)setResultInternal thread 1:setResultHandler(), holding deferredResult lock , requiring tomcat lock
|
Juergen Hoeller commented I've revised |
Rossen Stoyanchev commented Looks much better this way. I'm wondering if it's worth moving the timeout callback after setting the "timeout result" in a finally block. It is only a callback that can't influence or alter timeout handling. Either way a try-finally might be good to ensure setResultInternal is reached. |
Juergen Hoeller commented Hmm, |
Rossen Stoyanchev commented Oops, good point indeed that the callback can set the DeferredResult (even says so in onTimeout :)). So yes it needs to stay as it is with a try-finally for the existing sequence. One more point though that if |
yan.zhang opened SPR-14978 and commented
!bug.jpg|thumbnail!
It looks like a concurrency bug.
"this.resultHandler.handleResult(this.result);" may be executed twice.
I think it shoule be:
Affects: 3.2.17, 4.2.8, 4.3.4, 5.0 M3
Reference URL: https://github.com/spring-projects/spring-framework/blob/v5.0.0.M3/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java
Attachments:
Issue Links:
Backported to: 4.2.9, 3.2.18
The text was updated successfully, but these errors were encountered: