rschildmeijer / deft

High performance non blocking web framework
http://www.deftserver.org
Apache License 2.0
197 stars 25 forks source link

Timeout is not cancelled upon onFailure in AsynchronousHttpClient #126

Closed rschildmeijer closed 13 years ago

rschildmeijer commented 13 years ago

e,g Slightly modified AsynchronousHttpClientExample.java:

public static void main(String[] args) {
    AsynchronousHttpClient client = new AsynchronousHttpClient();
    client.fetch("http://tasdfadst.se/start/", new ResultCallback());
    IOLoop.INSTANCE.start();
}

private static class ResultCallback implements AsyncResult<HttpResponse> {

    @Override public void onFailure(Throwable caught) { out.println("exception caught: " + caught); }

    @Override public void onSuccess(HttpResponse response) { out.println("http resonse:\n" + response); }

}

Here we expect onFailure to be called with a java.nio.channels.UnresolvedAddressException

because of the unresolvable hostname.

The problem is that we dont cancel the timeout (upon onFailure) that associated with the connect call, and hence, we will get another onFailure-callback after the timeout has reached its deadline (~15s).

Solution: The timeout should be cancelled upon connect failure

rschildmeijer commented 13 years ago

Implements #126 (Timeout is not cancelled upon onFailure in AsynchronousHttpClient) (closed by e26464e378b221000cf99dc50e1577a0137a0c3a) patch by rschildmeijer