mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8221882: Use fiber-friendly java.util.concurrent.locks in JSSE
Reviewed-by: alanb, dfuchs
This commit is contained in:
parent
6d617481d4
commit
8263b618ba
22 changed files with 1672 additions and 1020 deletions
|
@ -29,6 +29,7 @@ import java.net.Socket;
|
|||
import java.security.*;
|
||||
import java.security.cert.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import javax.net.ssl.*;
|
||||
import sun.security.util.AnchorCertificates;
|
||||
import sun.security.util.HostnameChecker;
|
||||
|
@ -63,6 +64,8 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager
|
|||
// the different extension checks. They are initialized lazily on demand.
|
||||
private volatile Validator clientValidator, serverValidator;
|
||||
|
||||
private final ReentrantLock validatorLock = new ReentrantLock();
|
||||
|
||||
X509TrustManagerImpl(String validatorType,
|
||||
Collection<X509Certificate> trustedCerts) {
|
||||
|
||||
|
@ -157,12 +160,15 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager
|
|||
if (isClient) {
|
||||
v = clientValidator;
|
||||
if (v == null) {
|
||||
synchronized (this) {
|
||||
validatorLock.lock();
|
||||
try {
|
||||
v = clientValidator;
|
||||
if (v == null) {
|
||||
v = getValidator(Validator.VAR_TLS_CLIENT);
|
||||
clientValidator = v;
|
||||
}
|
||||
} finally {
|
||||
validatorLock.unlock();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -170,12 +176,15 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager
|
|||
// (guaranteed under the new Tiger memory model)
|
||||
v = serverValidator;
|
||||
if (v == null) {
|
||||
synchronized (this) {
|
||||
validatorLock.lock();
|
||||
try {
|
||||
v = serverValidator;
|
||||
if (v == null) {
|
||||
v = getValidator(Validator.VAR_TLS_SERVER);
|
||||
serverValidator = v;
|
||||
}
|
||||
} finally {
|
||||
validatorLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue