RFR: 8336815: Socket.bind/connect and ServerSocket.bind/accept do not specify behavior when already bound, connected or closed [v3]
Alan Bateman
alanb at openjdk.org
Sat Jul 20 15:48:31 UTC 2024
On Sat, 20 Jul 2024 14:44:53 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
> When writing this test, I noticed that a few other methods on ServerSocket and Socket also needed an update to their specification to match their current implementation.
Thanks, and doesn't surprise me that it's not explicitly specified in other methods. I think the spec change looks okay although I think it would be better to not repeat the "if" in each of the thrown, e.g. "if the bind operation fails, the socket is already bound, or the socket is closed". Up to you if you want to stick with what you have.
Reading the updates, some of the socket options have "an error in the underlying protocol, such as a TCP error" but none of these methods are doing I/O, they are just setting or reading socket options. They should say "if there is an error SO_RCVBUF" or whatever. It's not important here, it's just jumping out when reading these old descriptions.
You asked about specifying the more specific SocketException. These APIs are pluggable via SocketImpl so specifying a more specific exception could potentially invalidate existing implementations. I don't know if there are any other implementations in 2024 but I think changing anything here would require further thought on the compatibility impact.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20268#discussion_r1685475102
More information about the net-dev
mailing list