On Tue, 10 Sep 2024 14:44:35 GMT, Daniel Fuchs <dfu...@openjdk.org> wrote:
>> src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java line 442: >> >>> 440: // use 1L below to ensure conversion to long and avoid >>> potential >>> 441: // integer overflow (timeout is an int). >>> 442: // no point in supporting timeout > Integer.MAX_VALUE, >>> clamp if needed >> >> if I have read this correctly, timeout is of type int, thus int >> Math.clamp(int, int, int) is being called returning type int and promoting >> to long. Are there any side effects to consider here? And as timeoutLeft >> (or remainingTimeout) and pktTimeout were both int and now is type long, >> then why have timeout declared as type int ? >> >> consistency in various declared "timeout" variables' type ? > > If I'm not mistaken here it's `Math.clamp(long, long, long)` which is called > - because `timeout * (1L << retry)` is a long. We could make it more obvious > by using `0L` instead of `0` too. thanks for the clarification ... yes indeed, I didn't see the 1L as the original was (timeout * (1 << retry)) BUT I should have read the comment more precisely(small screens and no glasses !!) ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/20892#discussion_r1752428852