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 #6197

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -383,7 +384,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
14 changes: 11 additions & 3 deletions test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java
Expand Up @@ -210,12 +210,12 @@ 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
Expand Down Expand Up @@ -482,7 +482,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