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 2011/08/10 15:50:49 UTC

svn commit: r1156184 - /httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java

Author: olegk
Date: Wed Aug 10 13:50:49 2011
New Revision: 1156184

URL: http://svn.apache.org/viewvc?rev=1156184&view=rev
Log:
Make sure the state of the response consumer gets carried over to its respective future even if the HTTP exchange has been cancelled prematurely

Modified:
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java?rev=1156184&r1=1156183&r2=1156184&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java Wed Aug 10 13:50:49 2011
@@ -422,7 +422,16 @@ class DefaultAsyncRequestDirector<T> imp
         this.log.debug("HTTP exchange cancelled");
         try {
             this.responseConsumer.cancel();
-            this.resultCallback.cancelled(this);
+
+            T result = this.responseConsumer.getResult();
+            Exception ex = this.responseConsumer.getException();
+            if (ex != null) {
+                this.resultCallback.failed(ex, this);
+            } else if (result != null) {
+                this.resultCallback.completed(result, this);
+            } else {
+                this.resultCallback.cancelled(this);
+            }
         } catch (RuntimeException runex) {
             this.resultCallback.failed(runex, this);
             throw runex;