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



##########
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:
       I suppose an alternative and potentially simpler solution would be:
   AtomicBoolean completed is used exclusively to guard internally _setting_ 
`this.result` and `this.completed`, but is no longer used by `public boolean 
isDone()`
   
   isDone may be updated to make two volatile reads.
   ```java
   public boolean isDone() {
      return result != null || ex != null;
   }
   ```
   
   This way isDone and getException/getResult always agree. What do you think?




-- 
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to