< prev index next >

src/share/classes/sun/security/ssl/JsseJce.java

Print this page
rev 11548 : 8133070: Hot lock on BulkCipher.isAvailable
Reviewed-by: mullan
Contributed-by: xuelei.fan@oracle.com, kungu.mjh@alibaba-inc.com

*** 53,67 **** */ final class JsseJce { private final static ProviderList fipsProviderList; - // Flag indicating whether EC crypto is available. - // If null, then we have not checked yet. - // If yes, then all the EC based crypto we need is available. - private static Boolean ecAvailable; - // Flag indicating whether Kerberos crypto is available. // If true, then all the Kerberos-based crypto we need is available. private final static boolean kerberosAvailable; static { boolean temp; --- 53,62 ----
*** 193,220 **** private JsseJce() { // no instantiation of this class } ! synchronized static boolean isEcAvailable() { ! if (ecAvailable == null) { ! try { ! JsseJce.getSignature(SIGNATURE_ECDSA); ! JsseJce.getSignature(SIGNATURE_RAWECDSA); ! JsseJce.getKeyAgreement("ECDH"); ! JsseJce.getKeyFactory("EC"); ! JsseJce.getKeyPairGenerator("EC"); ! ecAvailable = true; ! } catch (Exception e) { ! ecAvailable = false; ! } ! } ! return ecAvailable; ! } ! ! synchronized static void clearEcAvailable() { ! ecAvailable = null; } static boolean isKerberosAvailable() { return kerberosAvailable; } --- 188,199 ---- private JsseJce() { // no instantiation of this class } ! static boolean isEcAvailable() { ! return EcAvailability.isAvailable; } static boolean isKerberosAvailable() { return kerberosAvailable; }
*** 412,417 **** --- 391,419 ---- if (fipsProviderList != null) { Providers.endThreadProviderList((ProviderList)o); } } + + // lazy initialization holder class idiom for static default parameters + // + // See Effective Java Second Edition: Item 71. + private static class EcAvailability { + // Is EC crypto available? + private final static boolean isAvailable; + + static { + boolean mediator = true; + try { + JsseJce.getSignature(SIGNATURE_ECDSA); + JsseJce.getSignature(SIGNATURE_RAWECDSA); + JsseJce.getKeyAgreement("ECDH"); + JsseJce.getKeyFactory("EC"); + JsseJce.getKeyPairGenerator("EC"); + } catch (Exception e) { + mediator = false; + } + + isAvailable = mediator; + } + } }
< prev index next >