On Wed, 14 Aug 2024 10:53:34 GMT, Darragh Clarke <[email protected]> wrote:
> I wonder in the case of timeout being equal to 0 what the best way to handle
> it is though?
The `HttpRequest.Builder.timeout()` doesn't allow for `0` (or negative) value
to be specified for the timeout duration. So if the request timeout is indeed
specified, then we can be sure that the nanos representation of it here will be
greater than 0. We could just add an `assert` for that, after converting it to
nanos (when the request timeout is present). Something like this untested code:
long timeoutNanos = TimeUnit.SECONDS.toNanos(5);
if(request.timeout().isPresent() {
final long rtNanos = request.timeout().get().getNano();
assert rtNanos > 0 : "unexpected request timeout: " + rtNanos;
timeoutNanos = Math.min(timeoutNanos, rt);
});
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20525#discussion_r1716732426