On Mon, 7 Nov 2022 20:26:54 GMT, Daniel Fuchs <[email protected]> wrote:
>> Aleksei Efimov has updated the pull request incrementally with one
>> additional commit since the last revision:
>>
>> Address review comments
>
> src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DNSDatagramChannelFactory.java
> line 279:
>
>> 277: } catch (IOException x) {
>> 278: // try again until maxtries == 0;
>> 279: }
>
> That can be simplified now:
>
> DatagramChannel dc = (family != null)
> ? DatagramChannel.open(family)
> : DatagramChannel.open();
> try {
> dc.bind(new InetSocketAddress(port));
> lastport = getLocalPort(dc);
> if (!recycled) history.add(port);
> return dc;
> } catch (IOException x) {
> dc.close();
> // try again until maxtries == 0;
> }
>
> There's probably no need to retry if the open call fails, as the next call to
> `open` is likely to fail too. So if `open` throws we should probably let it
> propagate upwards - (and declare openRandom() to throw IOException).
Thanks for suggestion - `openRandom` looks much simplier, no duplicated code
and in-sync with `openDefault`. I agree that it is reasonable not to retry
`open` call in failure case, and propagate `IOException`. Changed in
fa7ef18713930aa19f1f45672ed3181acd2a0e63
-------------
PR: https://git.openjdk.org/jdk/pull/11007