RFR: 8301701 : java/net/DatagramSocket/DatagramSocketMulticasting.java should be hardened [v2]
Daniel Fuchs
dfuchs at openjdk.org
Tue Feb 14 15:10:06 UTC 2023
On Tue, 14 Feb 2023 14:44:36 GMT, Darragh Clarke <duke at openjdk.org> wrote:
>> Updated `DatagramSocketMulticasting` to use Junit and also hardened the test to avoid occasional interference from other tests.
>>
>> - Test now uses Junit Assertions, in general if the assertion used had been `assertTrue(foo==bar)` I replaced it with `assertEquals(foo,bar)` though there are some cases where I used `assertTrue` or `assertFalse`
>> - `testSendReceive` now retries up to 3 times if a message from an unexpected port is received
>> - Both `testSendReceive` and `testSendNoReceive` both have messages that use the methods name instead of just "hello"
>>
>> Ran tiers 1-3 of tests as well as running this updated test to make sure it was stable
>
> Darragh Clarke has updated the pull request incrementally with one additional commit since the last revision:
>
> cleanup based on feedback
Changes requested by dfuchs (Reviewer).
test/jdk/java/net/DatagramSocket/DatagramSocketMulticasting.java line 331:
> 329: }
> 330:
> 331: assertNotEquals(i, MAX_TRIES, "testSendReceive: too many retries");
It would be good to log the content of the received datagram (address of the sender, + content as text) for debugging purpose. possibly the logging could be done whether the datagram matches or not. and maybe the interation number (i) could be included in the log message.
test/jdk/java/net/DatagramSocket/DatagramSocketMulticasting.java line 351:
> 349: byte[] message = text.getBytes("UTF-8");
> 350:
> 351: // send datagram to multicast group
In the code below it would also be good to log the unexpected message content, as a string (or possibly both as a plain string and as an hexadecimal string.
-------------
PR: https://git.openjdk.org/jdk/pull/12513
More information about the net-dev
mailing list