Blame pr2737-allow_multiple_pkcs11_library_initialisation_to_be_a_non_critical_error.patch

dfc5637
# HG changeset patch
dfc5637
# User andrew
dfc5637
# Date 1352129932 0
dfc5637
# Node ID e9c857dcb964dbfa5eef3a3590244cb4d999cf7a
dfc5637
# Parent  1406789608b76d0906881979335d685855f44190
dfc5637
Allow multiple PKCS11 library initialisation to be a non-critical error.
dfc5637
dfc5637
diff -r 1406789608b7 -r e9c857dcb964 src/share/classes/sun/security/pkcs11/Config.java
dfc5637
--- jdk8/jdk/src/share/classes/sun/security/pkcs11/Config.java Tue Oct 30 13:05:14 2012 +0000
dfc5637
+++ jdk8/jdk/src/share/classes/sun/security/pkcs11/Config.java Mon Nov 05 15:38:52 2012 +0000
dfc5637
@@ -52,6 +52,7 @@
dfc5637
     static final int ERR_HALT       = 1;
dfc5637
     static final int ERR_IGNORE_ALL = 2;
dfc5637
     static final int ERR_IGNORE_LIB = 3;
dfc5637
+    static final int ERR_IGNORE_MULTI_INIT = 4;
dfc5637
 
dfc5637
     // same as allowSingleThreadedModules but controlled via a system property
dfc5637
     // and applied to all providers. if set to false, no SunPKCS11 instances
dfc5637
@@ -980,6 +981,8 @@
dfc5637
             handleStartupErrors = ERR_IGNORE_LIB;
dfc5637
         } else if (val.equals("halt")) {
dfc5637
             handleStartupErrors = ERR_HALT;
dfc5637
+        } else if (val.equals("ignoreMultipleInitialisation")) {
dfc5637
+            handleStartupErrors = ERR_IGNORE_MULTI_INIT;
dfc5637
         } else {
dfc5637
             throw excToken("Invalid value for handleStartupErrors:");
dfc5637
         }
dfc5637
diff -r 1406789608b7 -r e9c857dcb964 src/share/classes/sun/security/pkcs11/SunPKCS11.java
dfc5637
--- jdk8/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java  Tue Oct 30 13:05:14 2012 +0000
dfc5637
+++ jdk8/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java  Mon Nov 05 15:38:52 2012 +0000
dfc5637
@@ -168,26 +168,37 @@
dfc5637
                 String nssLibraryDirectory = config.getNssLibraryDirectory();
dfc5637
                 String nssSecmodDirectory = config.getNssSecmodDirectory();
dfc5637
                 boolean nssOptimizeSpace = config.getNssOptimizeSpace();
dfc5637
+                int errorHandling = config.getHandleStartupErrors();
dfc5637
 
dfc5637
                 if (secmod.isInitialized()) {
dfc5637
                     if (nssSecmodDirectory != null) {
dfc5637
                         String s = secmod.getConfigDir();
dfc5637
                         if ((s != null) &&
dfc5637
                                 (s.equals(nssSecmodDirectory) == false)) {
dfc5637
-                            throw new ProviderException("Secmod directory "
dfc5637
-                                + nssSecmodDirectory
dfc5637
-                                + " invalid, NSS already initialized with "
dfc5637
-                                + s);
dfc5637
+                            String msg = "Secmod directory " + nssSecmodDirectory
dfc5637
+                                + " invalid, NSS already initialized with " + s;
dfc5637
+                            if (errorHandling == Config.ERR_IGNORE_MULTI_INIT ||
dfc5637
+                                errorHandling == Config.ERR_IGNORE_ALL) {
dfc5637
+                                throw new UnsupportedOperationException(msg);
dfc5637
+                            } else {
dfc5637
+                                throw new ProviderException(msg);
dfc5637
+                            }
dfc5637
                         }
dfc5637
                     }
dfc5637
                     if (nssLibraryDirectory != null) {
dfc5637
                         String s = secmod.getLibDir();
dfc5637
                         if ((s != null) &&
dfc5637
                                 (s.equals(nssLibraryDirectory) == false)) {
dfc5637
-                            throw new ProviderException("NSS library directory "
dfc5637
+                            String msg = "NSS library directory "
dfc5637
                                 + nssLibraryDirectory
dfc5637
                                 + " invalid, NSS already initialized with "
dfc5637
-                                + s);
dfc5637
+                                + s;
dfc5637
+                            if (errorHandling == Config.ERR_IGNORE_MULTI_INIT ||
dfc5637
+                                errorHandling == Config.ERR_IGNORE_ALL) {
dfc5637
+                                throw new UnsupportedOperationException(msg);
dfc5637
+                            } else {
dfc5637
+                                throw new ProviderException(msg);
dfc5637
+                            }
dfc5637
                         }
dfc5637
                     }
dfc5637
                 } else {