RFR[8237890]: 'DatagramPacket::getSocketAddress doesn't specify what happens if address or port are not set'

Patrick Concannon patrick.concannon at oracle.com
Fri Apr 10 10:16:16 UTC 2020


Hi,

Could someone please review my webrev and CSR for JDK-8237890 
'DatagramPacket::getSocketAddress doesn't specify what happens if 
address or port are not set' ?

DatagramPacket::getSocketAddress is misleading in that it can throw an 
IllegalArgumentException even though it doesn't take any arguments. This 
can occur if the port of a DatagramPacket is not set before a call to 
getSocketAddress is made.

In the recent fixJDK-8236940 
<https://bugs.openjdk.java.net/browse/JDK-8236940>, additional checks 
were addedto ensure DatagramPacket cannot besent to port 0. Following on 
from this update,the current fix changes the default port of a 
DatagramPacket from -1 to 0. An IllegalArgumentException will therefore 
no longer be thrown when getSocketAddress with no port set. Instead, an 
InetSocketAddress representing any local address with port 0 is returned.


bug: https://bugs.openjdk.java.net/browse/JDK-8237890
csr: https://bugs.openjdk.java.net/browse/JDK-8242483
webrev: http://cr.openjdk.java.net/~pconcannon/8237890/webrevs/webrev.00/



Kind regards,

Patrick

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/net-dev/attachments/20200410/bcf12ec0/attachment.htm>


More information about the net-dev mailing list