RFR 8224477 [13] java.net.Socket::setOption - implementation mismatch to spec
Alan Bateman
Alan.Bateman at oracle.com
Tue May 21 19:05:22 UTC 2019
On 21/05/2019 19:36, Chris Hegarty wrote:
> The get/setOption methods of java.net Socket, ServerSocket, and
> DatagramSocket, are specified to throw NullPointerException if the given
> option name is null ( rather than UnsupportedOperationException, which
> is currently thrown ). The implementation correctly did this in JDK 9 (
> on *nix platforms at least ), when the methods were added, but has since
> regressed.
>
> The fix is straight forward; explicitly check the given option name
> using Objects::requireNonNull, and update an existing regression test to
> ensure that this behaviour does not unwittingly regress.
>
> Webrev:
> https://cr.openjdk.java.net/~chegar/8224477/webrev.00/
>
There are two parts to the issue, one is missing null change (those
changes are fine), the other is throwing SocketException instead of
IllegalArgumentException for bad values. Maybe you are splitting that out?
I've had to do a big clean-up to OptionsTest as part of JDK-8221481 so
we might have to merge the changes. One nit is the patch here is all
the "->s" lines in nulls are missing a space.
-Alan
More information about the net-dev
mailing list