You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by GitBox <gi...@apache.org> on 2021/06/18 21:27:08 UTC

[GitHub] [httpcomponents-core] rschmitt commented on a change in pull request #293: Fix data race in StrictConnPool

rschmitt commented on a change in pull request #293:
URL: https://github.com/apache/httpcomponents-core/pull/293#discussion_r654649739



##########
File path: httpcore5/src/main/java/org/apache/hc/core5/pool/StrictConnPool.java
##########
@@ -699,14 +699,18 @@ public boolean isDone() {
         }
 
         public void failed(final Exception ex) {
-            if (this.completed.compareAndSet(false, true)) {
-                this.ex = ex;
+            synchronized (this.completed) {

Review comment:
       |Thread A | Thread B|
   |-|-|
   |Set `completed` to true ||
   ||Call `isDone()`, which returns `true`|
   ||Call `getResult()`/`getException()`, which return `null`|
   |Set `ex`/`result`||
   
   I found this race condition by inspection. I'm trying to track down a connection leak that we're continuing to get reports about. In the absence of a repro, I've resorted to auditing the code. I don't know if this race condition results in an actual bug, or is just benign, but either way there's no reason not to fix it.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org