Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
/ jdk15u-dev Public archive

Commit c9a3110

Browse files
author
Yuri Nesterenko
committed
8274736: Concurrent read/close of SSLSockets causes SSLSessions to be invalidated unnecessarily
Backport-of: 8822d41fdcc2c2d568badd72635dc587d21dbd63
1 parent 8612163 commit c9a3110

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;
@@ -382,7 +383,12 @@ SSLException fatal(Alert alert, String diagnostic,
382383

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

388394
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
@@ -484,7 +484,15 @@ public static SSLContext createSSLContext(
484484
* Both sides can throw exceptions, but do you have a preference
485485
* as to which side should be the main thread.
486486
*/
487-
private static final boolean separateServerThread = false;
487+
private final boolean separateServerThread;
488+
489+
public SSLSocketTemplate() {
490+
this(false);
491+
}
492+
493+
public SSLSocketTemplate(boolean sepSrvThread) {
494+
this.separateServerThread = sepSrvThread;
495+
}
488496

489497
/*
490498
* Boot up the testing, used to drive remainder of the test.

0 commit comments

Comments
 (0)