8053479: (dc) DatagramChannel.read() throws exception instead of discarding data when buffer too small
Alan Bateman
Alan.Bateman at oracle.com
Wed Jan 15 11:33:07 UTC 2020
On 15/01/2020 10:44, Claes Redestad wrote:
> Looks good to me (although you probably want a review from someone
> more knowledgeable in the area).
>
> Nit: src/java.base/windows/native/libnio/ch/DatagramDispatcher.c L70
> indentation looks off by a space
>
> In the test the randomization of the byte array doesn't seem
> instrumental to what's being tested. Maybe preferable to just fill the
> buffer with some (constant?) value and drop the @randomness tag.
Thanks for looking at it. You are right that the buffer contents don't
influence the test but non-zero elements are needed to test that the
truncated datagram was read into the buffer (or buffers in the case of
the scattering read). The only reason it used Random was because of
other tests in this area, probably should move away from that. I've
updated it in-place to just cycle through the byte values:
- Random rand = new Random();
- rand.nextBytes(buffer.array());
+ IntStream.range(0, size).forEach(i -> buffer.put((byte)i));
+ buffer.flip();
-Alan
More information about the nio-dev
mailing list