On Mon, 7 Nov 2022 15:41:40 GMT, Aleksei Efimov <aefi...@openjdk.org> wrote:

>> src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java line 185:
>> 
>>> 183:     public void close() {
>>> 184:         try {
>>> 185:             udpChannelSelector.close();
>> 
>> Do you think we should now maintain a `closed` boolean flag in this class to 
>> keep track of whether this underlying selector has been closed? 
>> 
>> The javadoc of `Selector.close()` states that any subsequent use of the 
>> selector will throw a `ClosedSelectorException`. A `ClosedSelectorException` 
>> is a `RuntimeException`, so if a closed `DnsClient` gets used (for example a 
>> `query()` gets triggered) then from what I can see it will end up 
>> propagating this `ClosedSelectorException` out of these class methods 
>> instead of the declared compile time exceptions.
>> 
>> Maintaining a `closed` flag could allow us to use that flag to check in 
>> these methods (where we use the selector) and throw a more appropriate 
>> exception.
>
> Good point - planning to address the closed selector in the `blockingReceive` 
> method by calling `udpChannelSelector.isOpen()`.

Addressed it by catching `ClosedSelectorException` and wrapping it into JNDI's 
`CommunicationException` in 55dd0a4a

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

PR: https://git.openjdk.org/jdk/pull/11007

Reply via email to