Skip to content

8379549: [lworld] sun/security/ssl/SSLSocketImpl/SSLSocketSSLEngineCloseInbound.java failed with SocketException: Connection reset by peer#30340

Open
haimaychao wants to merge 1 commit intoopenjdk:masterfrom
haimaychao:JDK-8379549

Conversation

@haimaychao
Copy link
Contributor

@haimaychao haimaychao commented Mar 20, 2026

The SSLSocketSSLEngineCloseInbound.java test runs with different protocols, namely TLSv1.3, TLSv1.2, TLSv1.1, TLSv1, and TLS. The test log file shows that it completed successfully for the first four protocols, but it failed when running with protocol=TLS. Protocol TLS is resolved to TLSv1.3. The failure in the test is a timing-related issue, that server continues with write() after the client has already closed its side of the connection. This change removes the race condition by synchronizing the client and server with CountDownLatch.

Have validated the change to ensure the test to pass (with JTREG=REPEAT_COUNT=50).


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8379549: [lworld] sun/security/ssl/SSLSocketImpl/SSLSocketSSLEngineCloseInbound.java failed with SocketException: Connection reset by peer (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/30340/head:pull/30340
$ git checkout pull/30340

Update a local copy of the PR:
$ git checkout pull/30340
$ git pull https://git.openjdk.org/jdk.git pull/30340/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30340

View PR using the GUI difftool:
$ git pr show -t 30340

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/30340.diff

Using Webrev

Link to Webrev Comment

…oseInbound.java failed with SocketException: Connection reset by peer
@bridgekeeper
Copy link

bridgekeeper bot commented Mar 20, 2026

👋 Welcome back hchao! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Mar 20, 2026

@haimaychao This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8379549: [lworld] sun/security/ssl/SSLSocketImpl/SSLSocketSSLEngineCloseInbound.java failed with SocketException: Connection reset by peer

Reviewed-by: dcubed, wetmore

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 13 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the security security-dev@openjdk.org label Mar 20, 2026
@openjdk
Copy link

openjdk bot commented Mar 20, 2026

@haimaychao The following label will be automatically applied to this pull request:

  • security

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 20, 2026
@mlbridge
Copy link

mlbridge bot commented Mar 20, 2026

Webrevs

Copy link
Member

@dcubed-ojdk dcubed-ojdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the use of CountDownLatch instead of sleep!

Thumbs up.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 20, 2026
Copy link
Member

@myankelev myankelev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments

/*
* Enables logging of the SSL/TLS operations.
*/
private static final boolean logging = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this logging is always set to true I personally don't think this should be even included. What do you think about removing it and always logging?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no objections to the additional configuration options. (i.e. leaving as is.)

* including specific handshake messages, and might be best examined
* after gaining some familiarity with this application.
*/
private static final boolean debug = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How abut making the ssl debug option as a part of @run? It is always false as well which means that it does nothing atm.

If you believe it's needed, could you please change it so it takes a boolean system property test.debug? Like this:

Boolean.getBoolean("test.debug");

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to output the ssl debugging information by default, it just adds lots of extra output that is usually never looked at. If there is a problem with this test, developers can quickly toggle the switch to get the needed debug info.

We just turned the default JSSE debug output off in many unneeded test cases. (JDK-8368493) No need to turn it back on.

During the review of JDK-8368493, there was a suggestion to update all of the JSSE test cases to use test.debug. We could consider that, but let's do that as a unified chunk of work, rather than 1-offs here.

Thanks.

* read() ... ChangeCipherSpec
* read() ... Finished
*/
import javax.net.ssl.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: wildcard imports

}

// Server signals client it has finished writing
serverReadyLatch.countDown();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: what if exceptions are thrown, would the test just time out? Wouldn't it make sense to release the latch on the exceptions too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or in the finally block?

public void run() {
// client-side socket
try (SSLSocket sslSocket = (SSLSocket)sslc.getSocketFactory().
createSocket("localhost", port)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please change this to loopback address since you are touching the file?


// server-side socket that will read
try (Socket socket = serverSocket.accept()) {
socket.setSoTimeout(500);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
socket.setSoTimeout((int)Utils.adjustTimeout(500));

Copy link
Contributor

@bradfordwetmore bradfordwetmore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments to previous comments, but otherwise looks ok to me.

}

// Server signals client it has finished writing
serverReadyLatch.countDown();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or in the finally block?

/*
* Enables logging of the SSL/TLS operations.
*/
private static final boolean logging = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no objections to the additional configuration options. (i.e. leaving as is.)

* including specific handshake messages, and might be best examined
* after gaining some familiarity with this application.
*/
private static final boolean debug = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to output the ssl debugging information by default, it just adds lots of extra output that is usually never looked at. If there is a problem with this test, developers can quickly toggle the switch to get the needed debug info.

We just turned the default JSSE debug output off in many unneeded test cases. (JDK-8368493) No need to turn it back on.

During the review of JDK-8368493, there was a suggestion to update all of the JSSE test cases to use test.debug. We could consider that, but let's do that as a unified chunk of work, rather than 1-offs here.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready Pull request is ready to be integrated rfr Pull request is ready for review security security-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

4 participants