8053479: (dc) DatagramChannel.read() throws exception instead of discarding data when buffer too small

Claes Redestad claes.redestad at oracle.com
Wed Jan 15 10:44:07 UTC 2020

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.


On 2020-01-15 10:04, Alan Bateman wrote:
> If the DatagramChannel receive or read methods are called with a buffer 
> that has fewer bytes remaining that is required for the datagram then 
> the remainder is silently discarded. This scenario isn't handled 
> correctly on Windows when the channel's socket is connected because the 
> implementation doesn't handle WSAEMSGSIZE. Not an issue on other 
> platforms and not an issue for the not-connected case on Windows. The 
> fix to handle WSAEMSGSIZE is very simple:
> http://cr.openjdk.java.net/~alanb/8053479/webrev/
> -Alan.

More information about the nio-dev mailing list