6998860: Signed jar file verification is currently creating many extra new Sun providers.
authormullan
Wed, 08 Dec 2010 10:21:48 -0800
changeset 7539 d9cc884e12aa
parent 7538 e7916d8751e0
child 7540 df3383a0e30d
6998860: Signed jar file verification is currently creating many extra new Sun providers. Reviewed-by: mchung
jdk/src/share/classes/sun/security/util/ManifestEntryVerifier.java
--- a/jdk/src/share/classes/sun/security/util/ManifestEntryVerifier.java	Tue Dec 07 13:29:20 2010 +0000
+++ b/jdk/src/share/classes/sun/security/util/ManifestEntryVerifier.java	Wed Dec 08 10:21:48 2010 -0800
@@ -44,6 +44,16 @@
 
     private static final Debug debug = Debug.getInstance("jar");
 
+    /**
+     * Holder class to lazily load Sun provider. NOTE: if
+     * Providers.getSunProvider returned a cached provider, we could avoid the
+     * need for caching the provider with this holder class; we should try to
+     * revisit this in JDK 8.
+     */
+    private static class SunProviderHolder {
+        private static final Provider instance = Providers.getSunProvider();
+    }
+
     /** the created digest objects */
     HashMap<String, MessageDigest> createdDigests;
 
@@ -125,7 +135,7 @@
                     try {
 
                         digest = MessageDigest.getInstance
-                                        (algorithm, Providers.getSunProvider());
+                                        (algorithm, SunProviderHolder.instance);
                         createdDigests.put(algorithm, digest);
                     } catch (NoSuchAlgorithmException nsae) {
                         // ignore