Fixes #6382 - HttpClient TimeoutException message reports transient values.

Now using consistently HttpConversation.getTimeout() to report the accurate value.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2021-06-10 11:33:58 +02:00
parent 738d3a9f80
commit 734d3b672c
3 changed files with 6 additions and 4 deletions

View File

@ -331,7 +331,7 @@ public abstract class HttpConnection implements Connection, Attachable
if (exchange != null)
{
HttpRequest request = exchange.getRequest();
request.abort(new TimeoutException("Total timeout " + request.getTimeout() + " ms elapsed"));
request.abort(new TimeoutException("Total timeout " + request.getConversation().getTimeout() + " ms elapsed"));
}
return false;
}

View File

@ -564,7 +564,7 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
protected boolean onExpired(HttpExchange exchange)
{
HttpRequest request = exchange.getRequest();
request.abort(new TimeoutException("Total timeout " + request.getTimeout() + " ms elapsed"));
request.abort(new TimeoutException("Total timeout " + request.getConversation().getTimeout() + " ms elapsed"));
return false;
}
}

View File

@ -511,14 +511,16 @@ public class HttpClientRedirectTest extends AbstractHttpClientServerTest
}
});
assertThrows(TimeoutException.class, () ->
long timeout = 1000;
TimeoutException timeoutException = assertThrows(TimeoutException.class, () ->
{
client.setMaxRedirects(-1);
client.newRequest("localhost", connector.getLocalPort())
.scheme(scenario.getScheme())
.timeout(1, TimeUnit.SECONDS)
.timeout(timeout, TimeUnit.MILLISECONDS)
.send();
});
assertThat(timeoutException.getMessage(), Matchers.containsString(String.valueOf(timeout)));
}
@ParameterizedTest