Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8274736: Concurrent read/close of SSLSockets causes SSLSessions to be invalidated unnecessarily #711

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package sun.security.ssl;

import java.io.IOException;
import java.net.SocketException;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;
Expand Down Expand Up @@ -365,7 +366,12 @@ SSLException fatal(Alert alert, String diagnostic,

// invalidate the session
if (conSession != null) {
conSession.invalidate();
// In the case of a low-layer transport error, we want to prevent
// the session from being invalidated since this is not a TLS-level
// error event.
if (!(cause instanceof SocketException)) {
conSession.invalidate();
}
}

if (handshakeContext != null &&
Expand Down
18 changes: 13 additions & 5 deletions test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,22 +209,22 @@ protected void configureServerSocket(SSLServerSocket socket) {
/*
* Is the server ready to serve?
*/
private final CountDownLatch serverCondition = new CountDownLatch(1);
protected final CountDownLatch serverCondition = new CountDownLatch(1);

/*
* Is the client ready to handshake?
*/
private final CountDownLatch clientCondition = new CountDownLatch(1);
protected final CountDownLatch clientCondition = new CountDownLatch(1);

/*
* What's the server port? Use any free port by default
*/
private volatile int serverPort = 0;
protected volatile int serverPort = 0;

/*
* Define the server side of the test.
*/
private void doServerSide() throws Exception {
protected void doServerSide() throws Exception {
// kick start the server side service
SSLContext context = createServerSSLContext();
SSLServerSocketFactory sslssf = context.getServerSocketFactory();
Expand Down Expand Up @@ -470,7 +470,15 @@ public static SSLContext createSSLContext(
* Both sides can throw exceptions, but do you have a preference
* as to which side should be the main thread.
*/
private static final boolean separateServerThread = false;
private final boolean separateServerThread;

public SSLSocketTemplate() {
this(false);
}

public SSLSocketTemplate(boolean sepSrvThread) {
this.separateServerThread = sepSrvThread;
}

/*
* Boot up the testing, used to drive remainder of the test.
Expand Down
Loading