Skip to content

Commit

Permalink
Fixes #6382 - HttpClient TimeoutException message reports transient v…
Browse files Browse the repository at this point in the history
…alues.

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

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed Jun 21, 2021
1 parent 738d3a9 commit 734d3b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Expand Up @@ -331,7 +331,7 @@ protected boolean onExpired(HttpChannel channel)
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;
}
Expand Down
Expand Up @@ -564,7 +564,7 @@ protected Iterator<HttpExchange> iterator()
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;
}
}
Expand Down
Expand Up @@ -511,14 +511,16 @@ protected void service(String target, Request jettyRequest, HttpServletRequest r
}
});

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
Expand Down

0 comments on commit 734d3b6

Please sign in to comment.