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

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
This commit is contained in:
Patrick Concannon 2020-04-22 12:34:09 +01:00
parent ac088b4631
commit 8e21a2a1e4
5 changed files with 109 additions and 55 deletions

View file

@ -209,7 +209,6 @@ public class DatagramSocketAdaptor
p.setPort(remote.getPort());
target = remote;
} else {
// throws IllegalArgumentException if port not set
target = (InetSocketAddress) p.getSocketAddress();
}
}