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

Aleksei Efimov aefimov at openjdk.org
Tue Sep 10 18:54:06 UTC 2024


On Tue, 10 Sep 2024 14:47:26 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> 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.

Santized both `retries` and initial `timeout` prop values in [b651829](https://github.com/openjdk/jdk/pull/20892/commits/b6518291f96244ce12ee1da1d9b740c4bd5b11f6)

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

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


More information about the core-libs-dev mailing list