Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
5.1.3
-
None
Description
Hi,
it seems that when connection timeout occurs on http call, resulting exception is different depending on whether HttpHost is passed to execute method or not.
I am using
public final <T> Future<T> execute( final HttpHost target, final AsyncRequestProducer requestProducer, final AsyncResponseConsumer<T> responseConsumer, final HandlerFactory<AsyncPushConsumer> pushHandlerFactory, final HttpContext context, final FutureCallback<T> callback)
method to execute the request. But the resulting exception depends on whether `target` is null or not.
When target is null, and connection timeout occurs, then the result is org.apache.hc.client5.http.ConnectTimeoutException (correct), but when I provide the target instance myself, then the result is java.net.SocketTimeoutException.
I think the problem is within org.apache.hc.client5.http.impl.nio.MultihomeIOSessionRequester#connect
Here when the target is provided, the remoteAddress is not null, and the `connectionInitiator.connect` is called directly. When SocketTimeoutException is throws here, it is passed directly to the callback
But when the address is not provided, then connectionInitiator.connect is called later with custom callback. This custom callback also handles the SocketTimeoutException and rethrows ConnectTimeoutException
I would expect that for both cases the exception will be the same. Or am I doing something wrong here.
Thanks for info