hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1435143 - in /httpcomponents/httpcore/trunk: RELEASE_NOTES.txt httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java
Date Fri, 18 Jan 2013 14:06:59 GMT
Author: olegk
Date: Fri Jan 18 14:06:59 2013
New Revision: 1435143

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

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

Modified: httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?rev=1435143&r1=1435142&r2=1435143&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Fri Jan 18 14:06:59 2013
@@ -1,6 +1,9 @@
 Changes since 4.3-ALPHA1 
 -------------------
 
+* [HTTPCORE-331] BasicFuture no longer executes notification callbacks inside a synchronized
block.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCORE-330] Clarify InputStreamEntity length constructor argument.
   Contributed by John McCarthy <jmsignup at gmail.com>
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java?rev=1435143&r1=1435142&r2=1435143&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java
Fri Jan 18 14:06:59 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(final 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;
     }
 



Mime
View raw message