RFR: 8339538: Wrong timeout computations in DnsClient [v5]

Daniel Fuchs dfuchs at openjdk.org
Tue Sep 10 14:50:06 UTC 2024


On Tue, 10 Sep 2024 08:39:15 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:

>> Aleksei Efimov has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Measure time the caller spent waiting. Simplify timeoutLeft computation
>
> src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java line 443:
> 
>> 441:                 // integer overflow (timeout is an int).
>> 442:                 // no point in supporting timeout > Integer.MAX_VALUE, clamp if needed
>> 443:                 long pktTimeout = Math.clamp(timeout * (1L << retry), 0, Integer.MAX_VALUE);
> 
> we may also need to clamp retry to [0,31]. or even less.

Agreed - though I don't think it matter much. If the shift overflows to negative `pktTimeout` would become 0 which would be interpreted as wait forever.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20892#discussion_r1752134498


More information about the core-libs-dev mailing list