< prev index next >

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

Print this page

        

@@ -28,11 +28,10 @@
 import java.io.*;
 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.action.GetPropertyAction;
 import sun.security.provider.certpath.AlgorithmChecker;
 import sun.security.validator.Validator;
 

@@ -68,12 +67,10 @@
     private static final Collection<CipherSuite> serverCustomizedCipherSuites =
             getCustomizedCipherSuites("jdk.tls.server.cipherSuites");
 
     private volatile StatusResponseManager statusResponseManager;
 
-    private final ReentrantLock contextLock = new ReentrantLock();
-
     SSLContextImpl() {
         ephemeralKeyManager = new EphemeralKeyManager();
         clientCache = new SSLSessionContextImpl();
         serverCache = new SSLSessionContextImpl();
     }

@@ -231,37 +228,31 @@
     }
 
     // Used for DTLS in server mode only.
     HelloCookieManager getHelloCookieManager(ProtocolVersion protocolVersion) {
         if (helloCookieManagerBuilder == null) {
-            contextLock.lock();
-            try {
+            synchronized (this) {
                 if (helloCookieManagerBuilder == null) {
                     helloCookieManagerBuilder =
                             new HelloCookieManager.Builder(secureRandom);
                 }
-            } finally {
-                contextLock.unlock();
             }
         }
 
         return helloCookieManagerBuilder.valueOf(protocolVersion);
     }
 
     StatusResponseManager getStatusResponseManager() {
         if (serverEnableStapling && statusResponseManager == null) {
-            contextLock.lock();
-            try {
+            synchronized (this) {
                 if (statusResponseManager == null) {
                     if (SSLLogger.isOn && SSLLogger.isOn("ssl,sslctx")) {
                         SSLLogger.finest(
                                 "Initializing StatusResponseManager");
                     }
                     statusResponseManager = new StatusResponseManager();
                 }
-            } finally {
-                contextLock.unlock();
             }
         }
 
         return statusResponseManager;
     }
< prev index next >