hg: jdk/sandbox: 8237890: DatagramPacket::getSocketAddress doesn't specify what happens if address or port are not set
chris.hegarty at oracle.com
chris.hegarty at oracle.com
Wed Apr 22 11:45:25 UTC 2020
Changeset: 37fb240579e5
Author: pconcannon
Date: 2020-04-22 12:34 +0100
URL: https://hg.openjdk.java.net/jdk/sandbox/rev/37fb240579e5
8237890: DatagramPacket::getSocketAddress doesn't specify what happens if address or port are not set
Summary: This fix changes the default port of a DatagramPacket from -1 to 0, which changes the behaviour of calling getSocketAddress with no port set from throwing an IAE to returning an InetSocketAddress representing any local address with port 0.
Reviewed-by: alanb, chegar, dfuchs
! src/java.base/share/classes/java/net/DatagramPacket.java
! src/java.base/share/classes/sun/nio/ch/DatagramSocketAdaptor.java
! test/jdk/java/net/DatagramPacket/Constructor.java
+ test/jdk/java/net/DatagramPacket/Getters.java
! test/jdk/java/net/DatagramSocket/SendCheck.java
More information about the jdk-sandbox-changes
mailing list