Simple socket connection fails with TCP Connection Reset in case of connecting to the SSL Server.
SSL Server fails as expected: "javax.net.ssl.SSLException: Unsupported or unrecognized SSL message"
The client connection fails with:
java.net.SocketException: "Connection reset"
It happens because of SSL server does not clean the input stream before closing the underlying socket. As result, it causes TCP connection resets on some platforms.
JDK8 TLSv1.2 implementation did not have such an issue because of it explicitly clean the input stream before closing the socket : https://hg.openjdk.java.net/jdk8u/jdk8u-dev/jdk/file/fde7fd2a2fd2/src/share/classes/sun/security/ssl/SSLSocketImpl.java#l1932
Suggest doing the same in the TLSv1.3 implementation.
Please note: issue reproduced with the PlainSocketImpl only. JDK13 and higher should be run with -Djdk.net.usePlainSocketImpl=true option. JDK8 and JDK11 reproduce this issue in the default configuration.