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

Commit d959f81

Browse files
author
Yuri Nesterenko
committed
8274736: Concurrent read/close of SSLSockets causes SSLSessions to be invalidated unnecessarily
Reviewed-by: dcherepanov Backport-of: 8822d41fdcc2c2d568badd72635dc587d21dbd63
1 parent e77beca commit d959f81

File tree

3 files changed

+431
-4
lines changed

3 files changed

+431
-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;
@@ -338,7 +339,12 @@ SSLException fatal(Alert alert, String diagnostic,
338339

339340
// invalidate the session
340341
if (conSession != null) {
341-
conSession.invalidate();
342+
// In the case of a low-layer transport error, we want to prevent
343+
// the session from being invalidated since this is not a TLS-level
344+
// error event.
345+
if (!(cause instanceof SocketException)) {
346+
conSession.invalidate();
347+
}
342348
}
343349

344350
if (handshakeContext != null &&

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

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

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

219219
/*
220220
* What's the server port? Use any free port by default
@@ -468,7 +468,15 @@ public static SSLContext createSSLContext(
468468
* Both sides can throw exceptions, but do you have a preference
469469
* as to which side should be the main thread.
470470
*/
471-
private static final boolean separateServerThread = false;
471+
private final boolean separateServerThread;
472+
473+
public SSLSocketTemplate() {
474+
this(false);
475+
}
476+
477+
public SSLSocketTemplate(boolean sepSrvThread) {
478+
this.separateServerThread = sepSrvThread;
479+
}
472480

473481
/*
474482
* Boot up the testing, used to drive remainder of the test.

0 commit comments

Comments
 (0)