changeset 48080:18a4438eb690

8185855: Debug exception stacks should be clearer Reviewed-by: mullan, ascarpino
author coffeys
date Wed, 06 Dec 2017 14:33:33 +0000
parents eaa406097d93
children 89829dd3cc54
files src/java.base/share/classes/java/security/IdentityScope.java src/java.base/share/classes/java/security/Signature.java src/java.base/share/classes/sun/security/jca/ProviderList.java src/java.base/share/classes/sun/security/pkcs/PKCS8Key.java src/java.base/share/classes/sun/security/provider/AuthPolicyFile.java src/java.base/share/classes/sun/security/provider/DSA.java src/java.base/share/classes/sun/security/provider/PolicyFile.java src/java.base/share/classes/sun/security/util/AnchorCertificates.java src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java src/java.base/share/classes/sun/security/x509/CertificateExtensions.java src/java.base/share/classes/sun/security/x509/X509Key.java
diffstat 11 files changed, 15 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/security/IdentityScope.java	Wed Dec 06 13:47:35 2017 +0100
+++ b/src/java.base/share/classes/java/security/IdentityScope.java	Wed Dec 06 14:33:33 2017 +0000
@@ -90,8 +90,8 @@
             try {
                 Class.forName(classname);
             } catch (ClassNotFoundException e) {
-                //Security.error("unable to establish a system scope from " +
-                //             classname);
+                System.err.println("unable to establish a system scope from " +
+                             classname);
                 e.printStackTrace();
             }
         }
--- a/src/java.base/share/classes/java/security/Signature.java	Wed Dec 06 13:47:35 2017 +0100
+++ b/src/java.base/share/classes/java/security/Signature.java	Wed Dec 06 14:33:33 2017 +0000
@@ -1074,7 +1074,7 @@
                             debug.println("Further warnings of this type will "
                                 + "be suppressed");
                         }
-                        new Exception("Call trace").printStackTrace();
+                        new Exception("Debug call trace").printStackTrace();
                     }
                 }
                 Exception lastException = null;
--- a/src/java.base/share/classes/sun/security/jca/ProviderList.java	Wed Dec 06 13:47:35 2017 +0100
+++ b/src/java.base/share/classes/sun/security/jca/ProviderList.java	Wed Dec 06 14:33:33 2017 +0000
@@ -308,7 +308,7 @@
         }
         if (debug != null) {
             debug.println("Loading all providers");
-            new Exception("Call trace").printStackTrace();
+            new Exception("Debug Info. Call trace:").printStackTrace();
         }
         int n = 0;
         for (int i = 0; i < configs.length; i++) {
--- a/src/java.base/share/classes/sun/security/pkcs/PKCS8Key.java	Wed Dec 06 13:47:35 2017 +0100
+++ b/src/java.base/share/classes/sun/security/pkcs/PKCS8Key.java	Wed Dec 06 14:33:33 2017 +0000
@@ -346,7 +346,6 @@
             }
 
         } catch (IOException e) {
-            // e.printStackTrace ();
             throw new InvalidKeyException("IOException : " +
                                           e.getMessage());
         }
--- a/src/java.base/share/classes/sun/security/provider/AuthPolicyFile.java	Wed Dec 06 13:47:35 2017 +0100
+++ b/src/java.base/share/classes/sun/security/provider/AuthPolicyFile.java	Wed Dec 06 14:33:33 2017 +0000
@@ -187,6 +187,7 @@
             } catch (Exception e) {
                 // ignore, treat it like we have no keystore
                 if (debug != null) {
+                    debug.println("Debug info only. No keystore.");
                     e.printStackTrace();
                 }
                 return null;
@@ -261,7 +262,7 @@
                 loaded_one = true;
             } catch (Exception e) {
                 if (debug != null) {
-                    debug.println("error reading policy " + e);
+                    debug.println("Debug info only. Error reading policy " + e);
                     e.printStackTrace();
                 }
                 // ignore that policy
--- a/src/java.base/share/classes/sun/security/provider/DSA.java	Wed Dec 06 13:47:35 2017 +0100
+++ b/src/java.base/share/classes/sun/security/provider/DSA.java	Wed Dec 06 14:33:33 2017 +0000
@@ -490,18 +490,6 @@
         return printable;
     }
 
-    private static void debug(Exception e) {
-        if (debug) {
-            e.printStackTrace();
-        }
-    }
-
-    private static void debug(String s) {
-        if (debug) {
-            System.err.println(s);
-        }
-    }
-
     /**
      * Standard SHA224withDSA implementation as defined in FIPS186-3.
      */
--- a/src/java.base/share/classes/sun/security/provider/PolicyFile.java	Wed Dec 06 13:47:35 2017 +0100
+++ b/src/java.base/share/classes/sun/security/provider/PolicyFile.java	Wed Dec 06 14:33:33 2017 +0000
@@ -512,7 +512,8 @@
                         }
                     } catch (Exception e) {
                         if (debug != null) {
-                            debug.println("error reading policy "+e);
+                            debug.println(
+                                "Debug info only. Error reading policy " +e);
                             e.printStackTrace();
                         }
                         // ignore that policy
@@ -559,6 +560,7 @@
             } catch (Exception e) {
                 // ignore, treat it like we have no keystore
                 if (debug != null) {
+                    debug.println("Debug info only. Ignoring exception.");
                     e.printStackTrace();
                 }
             }
--- a/src/java.base/share/classes/sun/security/util/AnchorCertificates.java	Wed Dec 06 13:47:35 2017 +0100
+++ b/src/java.base/share/classes/sun/security/util/AnchorCertificates.java	Wed Dec 06 14:33:33 2017 +0000
@@ -75,8 +75,8 @@
                 } catch (Exception e) {
                     if (debug != null) {
                         debug.println("Error parsing cacerts");
+                        e.printStackTrace();
                     }
-                    e.printStackTrace();
                 }
                 return null;
             }
--- a/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java	Wed Dec 06 13:47:35 2017 +0100
+++ b/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java	Wed Dec 06 14:33:33 2017 +0000
@@ -386,8 +386,9 @@
                     if (e.getMessage() != null) {
                         debug.println(key + ":  " + e.getMessage());
                     } else {
-                        debug.println(key + ":  " + algorithm +
-                                " was disabled, no exception msg given.");
+                        debug.println("Debug info only. " +  key + ":  " +
+                            algorithm +
+                            " was disabled, no exception msg given.");
                         e.printStackTrace();
                     }
                 }
--- a/src/java.base/share/classes/sun/security/x509/CertificateExtensions.java	Wed Dec 06 13:47:35 2017 +0100
+++ b/src/java.base/share/classes/sun/security/x509/CertificateExtensions.java	Wed Dec 06 14:33:33 2017 +0000
@@ -124,7 +124,8 @@
                 unparseableExtensions.put(ext.getExtensionId().toString(),
                         new UnparseableExtension(ext, e));
                 if (debug != null) {
-                    debug.println("Error parsing extension: " + ext);
+                    debug.println("Debug info only." +
+                       " Error parsing extension: " + ext);
                     e.printStackTrace();
                     HexDumpEncoder h = new HexDumpEncoder();
                     System.err.println(h.encodeBuffer(ext.getExtensionValue()));
--- a/src/java.base/share/classes/sun/security/x509/X509Key.java	Wed Dec 06 13:47:35 2017 +0100
+++ b/src/java.base/share/classes/sun/security/x509/X509Key.java	Wed Dec 06 14:33:33 2017 +0000
@@ -392,7 +392,6 @@
                 throw new InvalidKeyException ("excess key data");
 
         } catch (IOException e) {
-            // e.printStackTrace ();
             throw new InvalidKeyException("IOException: " +
                                           e.getMessage());
         }