changeset 3224:291128e77395

6998860: Signed jar file verification is currently creating many extra new Sun providers. Reviewed-by: mchung
author mullan
date Wed, 08 Dec 2010 10:21:48 -0800
parents 9e173410b4d5
children acce526a49a7
files src/share/classes/sun/security/util/ManifestEntryVerifier.java
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/security/util/ManifestEntryVerifier.java	Tue Dec 07 13:29:20 2010 +0000
+++ b/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