8220493: Prepare Socket/ServerSocket for alternative platform SocketImpl
Alan Bateman
Alan.Bateman at oracle.com
Tue Mar 12 12:30:55 UTC 2019
We have a branch in the sandbox named "niosocketimpl-branch" with a
replacement for the underlying implementation used by java.net.Socket
and ServerSocket. I've mentioned this in previous mails [1]. We also
have a draft JEP [2].
I'd like to get the changes that allow for the platform SocketImpl to be
replaced into jdk/jdk in advance of the JEP. The reasoning is to reduce
the size of the overall patch, make the changes easier to review, and
get some of the narly behavior changes out of the way before the main event.
To that end, I've created JDK-8220493 [3] to bring the "preparatory
changes" into jdk/jdk. A summary of the changes is:
- ServerSocket is changed to use a platform SocketImpl by default, it
used to use the SOCKS SocketImpl.
- Socket use a SOCKS SocketImpl by default. The SOCKS SocketImpl now
delegates to a platform SocketImpl rather than extending it. The HTTP
SocketImpl is also changed to delegate to a platform SocketImpl.
- ServerSocket.accept has been overhauled to disallow nonsensical
combinations of SocketImpl. For example, it is nuts to create a
ServerSocket using a custom SocketImpl and have it try to accept a
connection with a platform SocketImpl. There is a big matrix of possible
scenarios that are tested with a new combinations test. Chris, Michael
and I spent time on a white board going through all the possible
scenarios to make sure that all sane scenarios work as before, only the
nonsensical comminations are disallowed.
- Socket has been changed to wrap the input/output streams returned by
the underlying SocketImpl so that closing of these streams will close
the socket. This is important to allow for socket implementations
outside of the java.net package but it requires changes to JFR as it
instruments these changes.
I've created a CSR [4] to document the subtle behavior changes.
The webrev with the corresponding changes is here:
http://cr.openjdk.java.net/~alanb/8220493/0/webrev/
-Alan
[1]
https://mail.openjdk.java.net/pipermail/net-dev/2019-January/012135.html
[2] http://openjdk.java.net/jeps/8218559
[3] https://bugs.openjdk.java.net/browse/JDK-8220493
[4] https://bugs.openjdk.java.net/browse/JDK-8220494
More information about the hotspot-jfr-dev
mailing list