RFR: 8302845: Replace finalizer usage in JNDI DNS provider with Cleaner [v2]
Daniel Fuchs
dfuchs at openjdk.org
Sat May 6 09:53:18 UTC 2023
On Fri, 5 May 2023 19:08:27 GMT, Aleksei Efimov <aefimov at openjdk.org> wrote:
>> JNDI `DnsClient` has a finalize method to close its internal datagram channel selector.
>> The change proposed here replaces it with a cleaner to close the selector once the `DnsClient`
>> instance becomes phantom reachable.
>>
>> The change was tested with `jdk-tier1` to `jdk-tier3` test sets which showed no failures.
>
> Aleksei Efimov has updated the pull request incrementally with one additional commit since the last revision:
>
> fix comment
Changes requested by dfuchs (Reviewer).
src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java line 165:
> 163: // when this DNS client becomes phantom reachable
> 164: Selector sel = udpChannelSelector;
> 165: CleanerFactory.cleaner().register(this, () -> {
I believe this is not quite right. The Cleanable returned by the `register` method should be saved in a final field. And close() below should call `Cleanable::clean` instead of `udpChannelSelector.close()`
-------------
PR Review: https://git.openjdk.org/jdk/pull/13837#pullrequestreview-1415750869
PR Review Comment: https://git.openjdk.org/jdk/pull/13837#discussion_r1186672907
More information about the core-libs-dev
mailing list