< prev index next >

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

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -100,25 +100,29 @@
 
     /*
      * Basic container for credentials implemented as an inner class.
      */
     private static class X509Credentials {
-        final PrivateKey privateKey;
-        final X509Certificate[] certificates;
-        private final Set<X500Principal> issuerX500Principals;
+        PrivateKey privateKey;
+        X509Certificate[] certificates;
+        private Set<X500Principal> issuerX500Principals;
 
         X509Credentials(PrivateKey privateKey, X509Certificate[] certificates) {
             // assert privateKey and certificates != null
             this.privateKey = privateKey;
             this.certificates = certificates;
-            this.issuerX500Principals = new HashSet<>(certificates.length);
-            for (X509Certificate certificate : certificates) {
-                issuerX500Principals.add(certificate.getIssuerX500Principal());
-            }
         }
 
-        Set<X500Principal> getIssuerX500Principals() {
+        synchronized Set<X500Principal> getIssuerX500Principals() {
+            // lazy initialization
+            if (issuerX500Principals == null) {
+                issuerX500Principals = new HashSet<X500Principal>();
+                for (int i = 0; i < certificates.length; i++) {
+                    issuerX500Principals.add(
+                                certificates[i].getIssuerX500Principal());
+                }
+            }
             return issuerX500Principals;
         }
     }
 
     SunX509KeyManagerImpl(KeyStore ks, char[] password)
< prev index next >