RFR: 8164804: sun/security/ssl/SSLSocketImpl/CloseSocket.java makes not reliable time assumption

Daniel Fuchs dfuchs at openjdk.java.net
Tue May 4 16:12:51 UTC 2021


On Tue, 4 May 2021 15:12:39 GMT, Fernando Guallini <fguallini at openjdk.org> wrote:

> test sun/security/ssl/SSLSocketImpl/CloseSocket.java verifies the behavior when a server closes the socket connection during a handshake. The server was waiting a fixed 100ms before closing it, but there was no guarantee that the client started the handshake before or during that time frame 
> 
> With this changeset, the server is checking whether the client thread has initiated handshake, and retrying if needed after waiting a short time. In addition, the test is now reusing SSLSocketTemplate to simplify sockets configuration and client/server synchronization

test/jdk/sun/security/ssl/SSLSocketImpl/CloseSocket.java line 45:

> 43: public class CloseSocket extends SSLSocketTemplate {
> 44: 
> 45:     private static Thread clientThread = null;

Shouldn't this variable be `volatile`? If I'm not mistaken it's set in one thread and potentially read in a different thread? An alternative could be to use a CountDownLatch instead.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3856



More information about the security-dev mailing list