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
Implements #126 (Timeout is not cancelled upon onFailure in
AsynchronousHttpClient) (closed by e26464e378b221000cf99dc50e1577a0137a0c3a) patch by rschildmeijer
e,g Slightly modified AsynchronousHttpClientExample.java:
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