geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r612422 - /geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/ResponseFuture.java
Date Wed, 16 Jan 2008 11:24:44 GMT
Author: rickmcguire
Date: Wed Jan 16 03:24:34 2008
New Revision: 612422

URL: http://svn.apache.org/viewvc?rev=612422&view=rev
Log:
GERONIMO-3751 callbacks may not be completed when caller uses future.get() too to complete
request handling

Patch provided by Sangjin Lee. 


Modified:
    geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/ResponseFuture.java

Modified: geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/ResponseFuture.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/ResponseFuture.java?rev=612422&r1=612421&r2=612422&view=diff
==============================================================================
--- geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/ResponseFuture.java
(original)
+++ geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/ResponseFuture.java
Wed Jan 16 03:24:34 2008
@@ -91,10 +91,15 @@
      */
     @Override
     public void set(HttpResponseMessage v) {
-        super.set(v);
-        // fire the callback once the future is done
-        if (callback != null) {
-            callback.onResponse(v);
+        try {
+            // fire the callback before completing the future to 
+            // ensure everything gets handled before the future gets 
+            // completed. 
+            if (callback != null) {
+                callback.onResponse(v);
+            }
+        } finally {
+            super.set(v);
         }
     }
 
@@ -107,14 +112,19 @@
      */
     @Override
     public void setException(Throwable t) {
-        super.setException(t);
-        // fire the callback once the future is done
-        if (callback != null) {
-            if (t instanceof TimeoutException) {
-                callback.onTimeout();
-            } else {
-                callback.onException(t);
+        try {
+            // fire the callback before completing the future to 
+            // ensure everything gets handled before the future gets 
+            // completed. 
+            if (callback != null) {
+                if (t instanceof TimeoutException) {
+                    callback.onTimeout();
+                } else {
+                    callback.onException(t);
+                }
             }
+        } finally {
+            super.setException(t);
         }
     }
     



Mime
View raw message