Skip to content

Commit 6f2bdc0

Browse files
Prajwal Kumaraswamycoffeys
Prajwal Kumaraswamy
authored andcommitted
8274736: Concurrent read/close of SSLSockets causes SSLSessions to be invalidated unnecessarily
Backport-of: 8822d41fdcc2c2d568badd72635dc587d21dbd63
1 parent d998761 commit 6f2bdc0

File tree

3 files changed

+429
-4
lines changed

3 files changed

+429
-4
lines changed

src/java.base/share/classes/sun/security/ssl/TransportContext.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
package sun.security.ssl;
2727

2828
import java.io.IOException;
29+
import java.net.SocketException;
2930
import java.security.AccessControlContext;
3031
import java.security.AccessController;
3132
import java.security.PrivilegedAction;
@@ -383,7 +384,12 @@ SSLException fatal(Alert alert, String diagnostic,
383384

384385
// invalidate the session
385386
if (conSession != null) {
386-
conSession.invalidate();
387+
// In the case of a low-layer transport error, we want to prevent
388+
// the session from being invalidated since this is not a TLS-level
389+
// error event.
390+
if (!(cause instanceof SocketException)) {
391+
conSession.invalidate();
392+
}
387393
}
388394

389395
if (handshakeContext != null &&

test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ protected void configureServerSocket(SSLServerSocket socket) {
210210
/*
211211
* Is the server ready to serve?
212212
*/
213-
private final CountDownLatch serverCondition = new CountDownLatch(1);
213+
protected final CountDownLatch serverCondition = new CountDownLatch(1);
214214

215215
/*
216216
* Is the client ready to handshake?
217217
*/
218-
private final CountDownLatch clientCondition = new CountDownLatch(1);
218+
protected final CountDownLatch clientCondition = new CountDownLatch(1);
219219

220220
/*
221221
* What's the server port? Use any free port by default
@@ -482,7 +482,15 @@ public static SSLContext createSSLContext(
482482
* Both sides can throw exceptions, but do you have a preference
483483
* as to which side should be the main thread.
484484
*/
485-
private static final boolean separateServerThread = false;
485+
private final boolean separateServerThread;
486+
487+
public SSLSocketTemplate() {
488+
this(false);
489+
}
490+
491+
public SSLSocketTemplate(boolean sepSrvThread) {
492+
this.separateServerThread = sepSrvThread;
493+
}
486494

487495
/*
488496
* Boot up the testing, used to drive remainder of the test.

0 commit comments

Comments
 (0)