You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2013/01/18 15:07:19 UTC

svn commit: r1435144 - in /httpcomponents/httpcore/branches/4.2.x: RELEASE_NOTES.txt httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java

Author: olegk
Date: Fri Jan 18 14:07:18 2013
New Revision: 1435144

URL: http://svn.apache.org/viewvc?rev=1435144&view=rev
Log:
HTTPCORE-331: BasicFuture no longer executes notification callbacks inside a synchronized block

Modified:
    httpcomponents/httpcore/branches/4.2.x/RELEASE_NOTES.txt
    httpcomponents/httpcore/branches/4.2.x/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java

Modified: httpcomponents/httpcore/branches/4.2.x/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.2.x/RELEASE_NOTES.txt?rev=1435144&r1=1435143&r2=1435144&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.2.x/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/branches/4.2.x/RELEASE_NOTES.txt Fri Jan 18 14:07:18 2013
@@ -1,5 +1,8 @@
 Changes since 4.2.3
 
+* [HTTPCORE-331] BasicFuture no longer executes notification callbacks inside a synchronized block.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCORE-319] Non-blocking SSLIOSession can fail to shut down correctly when the underlying
   connection gets terminated abnormally by the opposite endpoint in case there is a truncated or
   corrupted encrypted content in the input buffer and there is still data in the output buffer

Modified: httpcomponents/httpcore/branches/4.2.x/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.2.x/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java?rev=1435144&r1=1435143&r2=1435144&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.2.x/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java (original)
+++ httpcomponents/httpcore/branches/4.2.x/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java Fri Jan 18 14:07:18 2013
@@ -100,41 +100,47 @@ public class BasicFuture<T> implements F
     }
 
     public synchronized boolean completed(final T result) {
-        if (this.completed) {
-            return false;
+        synchronized(this) {
+            if (this.completed) {
+                return false;
+            }
+            this.completed = true;
+            this.result = result;
+            notifyAll();
         }
-        this.completed = true;
-        this.result = result;
         if (this.callback != null) {
             this.callback.completed(result);
         }
-        notifyAll();
         return true;
     }
 
     public synchronized boolean failed(final Exception exception) {
-        if (this.completed) {
-            return false;
+        synchronized(this) {
+            if (this.completed) {
+                return false;
+            }
+            this.completed = true;
+            this.ex = exception;
+            notifyAll();
         }
-        this.completed = true;
-        this.ex = exception;
         if (this.callback != null) {
             this.callback.failed(exception);
         }
-        notifyAll();
         return true;
     }
 
     public synchronized boolean cancel(boolean mayInterruptIfRunning) {
-        if (this.completed) {
-            return false;
+        synchronized(this) {
+            if (this.completed) {
+                return false;
+            }
+            this.completed = true;
+            this.cancelled = true;
+            notifyAll();
         }
-        this.completed = true;
-        this.cancelled = true;
         if (this.callback != null) {
             this.callback.cancelled();
         }
-        notifyAll();
         return true;
     }