Skip to content

Commit

Permalink
Make sure the state of the response consumer gets carried over to its…
Browse files Browse the repository at this point in the history
… respective future even if the HTTP exchange has been cancelled prematurely

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpasyncclient/trunk@1156184 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
ok2c committed Aug 10, 2011
1 parent 64bda5b commit 82598b3
Showing 1 changed file with 10 additions and 1 deletion.
Expand Up @@ -422,7 +422,16 @@ public synchronized void cancel() {
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;
Expand Down

0 comments on commit 82598b3

Please sign in to comment.