RFR: 8278961: Enable debug logging in java/net/DatagramSocket/SendDatagramToBadAddress.java

Daniel Jeliński duke at openjdk.java.net
Mon Dec 20 08:54:26 UTC 2021


On Sat, 18 Dec 2021 02:35:24 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> test/jdk/java/net/DatagramSocket/SendDatagramToBadAddress.java line 182:
>> 
>>> 180:             } catch (InterruptedIOException ex) {
>>> 181:                 print ("socket timeout");
>>> 182:             } catch (Exception ex) {
>> 
>> Can we catch `PortUnreachableException` here instead?
>
> Here too I didn't want to change the current behaviour/code of the test. It's not just this catch block but even the one a few lines above which catches `InterruptedIOException`. Neither the `send()` nor the `receive()` APIs of `DatagramSocket` specify that they throw this specific exception, but the test seems to catch it and consider it a socket timeout. So I'm guessing this test and the catch block was written with some specific context in mind and I didn't want to change that part as part of this PR which only aims to enable logging by default. Plus like Mark notes, the spec says `PortUnreachableException` "may" be thrown and isn't guaranteed.

Right. Looks like `OSsupportsFeature` was used to filter out systems that don't send "port unreachable"; we could probably use it here if the failure turns out to be OS-specific.

Additional logs look fine.

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

PR: https://git.openjdk.java.net/jdk/pull/6883


More information about the net-dev mailing list