RFR: 8290714: Make com.sun.jndi.dns.DnsClient virtual threads friendly [v2]
Aleksei Efimov
aefimov at openjdk.org
Tue Nov 8 00:26:58 UTC 2022
On Mon, 7 Nov 2022 20:26:54 GMT, Daniel Fuchs <dfuchs at openjdk.org> 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
More information about the core-libs-dev
mailing list