On Fri, 26 Aug 2022 08:55:27 GMT, Daniel Fuchs <[email protected]> wrote:
>> Jaikiran Pai has updated the pull request incrementally with one additional
>> commit since the last revision:
>>
>> implement review comment
>
> src/java.base/share/classes/java/net/DatagramPacket.java line 399:
>
>> 397: * will be used for receiving data. The {@code length} plus the
>> 398: * {@link #getOffset() offset} must be lesser or equal to the
>> 399: * length of the packet's data buffer.
>
> The new text looks good to me. While you're at it I would suggest to rewrite
> the code that checks the length with something like:
>
>
> Preconditions.checkFromIndexSize(offset, length, buf.length,
>
> Preconditions.outOfBoundsExceptionFormatter(IllegalArgumentException::new));
>
>
> Then figure out if we have a unit test that already checks this, and if not,
> write one!
Hello Daniel, thank you for the review. I've updated the PR to implement the
code change you suggested.
There's already `test/jdk/java/net/DatagramPacket/Setters.java` which has
`testSetLength` to test this method. I've run the entire
`test/jdk/java/net/DatagramPacket` tests with this change and they passed fine.
I'll trigger a more comprehensive test run just to make sure nothing unexpected
shows up.
-------------
PR: https://git.openjdk.org/jdk/pull/10037