From 4e54e99912f246fed3391b032a28ba9686184f6d Mon Sep 17 00:00:00 2001 From: coffeys Date: Wed, 6 Dec 2017 14:33:33 +0000 Subject: [PATCH] 8185855: Debug exception stacks should be clearer Reviewed-by: mullan, ascarpino --- src/share/classes/java/security/IdentityScope.java | 4 ++-- src/share/classes/java/security/Signature.java | 2 +- src/share/classes/sun/security/jca/ProviderList.java | 2 +- src/share/classes/sun/security/pkcs/PKCS8Key.java | 1 - .../sun/security/provider/AuthPolicyFile.java | 3 ++- src/share/classes/sun/security/provider/DSA.java | 12 ------------ .../classes/sun/security/provider/PolicyFile.java | 4 +++- .../sun/security/util/AnchorCertificates.java | 2 +- .../sun/security/util/SignatureFileVerifier.java | 5 +++-- .../sun/security/x509/CertificateExtensions.java | 3 ++- src/share/classes/sun/security/x509/X509Key.java | 1 - 11 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/share/classes/java/security/IdentityScope.java b/src/share/classes/java/security/IdentityScope.java index 64c4a6343..7b18387a3 100644 --- a/src/share/classes/java/security/IdentityScope.java +++ b/src/share/classes/java/security/IdentityScope.java @@ -88,8 +88,8 @@ class IdentityScope extends Identity { 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(); } } diff --git a/src/share/classes/java/security/Signature.java b/src/share/classes/java/security/Signature.java index 1a34f0f2a..5232b9c46 100644 --- a/src/share/classes/java/security/Signature.java +++ b/src/share/classes/java/security/Signature.java @@ -1051,7 +1051,7 @@ public abstract class Signature extends SignatureSpi { debug.println("Further warnings of this type will " + "be suppressed"); } - new Exception("Call trace").printStackTrace(); + new Exception("Debug call trace").printStackTrace(); } } Exception lastException = null; diff --git a/src/share/classes/sun/security/jca/ProviderList.java b/src/share/classes/sun/security/jca/ProviderList.java index 66c826241..f800f1d23 100644 --- a/src/share/classes/sun/security/jca/ProviderList.java +++ b/src/share/classes/sun/security/jca/ProviderList.java @@ -275,7 +275,7 @@ public final class ProviderList { } 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++) { diff --git a/src/share/classes/sun/security/pkcs/PKCS8Key.java b/src/share/classes/sun/security/pkcs/PKCS8Key.java index 6f47c9ccc..1a56865da 100644 --- a/src/share/classes/sun/security/pkcs/PKCS8Key.java +++ b/src/share/classes/sun/security/pkcs/PKCS8Key.java @@ -347,7 +347,6 @@ public class PKCS8Key implements PrivateKey { } } catch (IOException e) { - // e.printStackTrace (); throw new InvalidKeyException("IOException : " + e.getMessage()); } diff --git a/src/share/classes/sun/security/provider/AuthPolicyFile.java b/src/share/classes/sun/security/provider/AuthPolicyFile.java index a13cee583..821ef8b6f 100644 --- a/src/share/classes/sun/security/provider/AuthPolicyFile.java +++ b/src/share/classes/sun/security/provider/AuthPolicyFile.java @@ -186,6 +186,7 @@ public class AuthPolicyFile extends javax.security.auth.Policy { } 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; @@ -260,7 +261,7 @@ public class AuthPolicyFile extends javax.security.auth.Policy { 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 diff --git a/src/share/classes/sun/security/provider/DSA.java b/src/share/classes/sun/security/provider/DSA.java index 665e1626e..98e2de978 100644 --- a/src/share/classes/sun/security/provider/DSA.java +++ b/src/share/classes/sun/security/provider/DSA.java @@ -434,18 +434,6 @@ abstract class DSA extends SignatureSpi { 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. */ diff --git a/src/share/classes/sun/security/provider/PolicyFile.java b/src/share/classes/sun/security/provider/PolicyFile.java index 9ff02c51e..5ed375c48 100644 --- a/src/share/classes/sun/security/provider/PolicyFile.java +++ b/src/share/classes/sun/security/provider/PolicyFile.java @@ -563,7 +563,8 @@ public class PolicyFile extends java.security.Policy { loaded_policy = 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 @@ -616,6 +617,7 @@ public class PolicyFile extends java.security.Policy { } catch (Exception e) { // ignore, treat it like we have no keystore if (debug != null) { + debug.println("Debug info only. Ignoring exception."); e.printStackTrace(); } } diff --git a/src/share/classes/sun/security/util/AnchorCertificates.java b/src/share/classes/sun/security/util/AnchorCertificates.java index e260dd44a..af77f8fda 100644 --- a/src/share/classes/sun/security/util/AnchorCertificates.java +++ b/src/share/classes/sun/security/util/AnchorCertificates.java @@ -75,8 +75,8 @@ public class AnchorCertificates { } catch (Exception e) { if (debug != null) { debug.println("Error parsing cacerts"); + e.printStackTrace(); } - e.printStackTrace(); } return null; } diff --git a/src/share/classes/sun/security/util/SignatureFileVerifier.java b/src/share/classes/sun/security/util/SignatureFileVerifier.java index 0663f0573..6c9d892ee 100644 --- a/src/share/classes/sun/security/util/SignatureFileVerifier.java +++ b/src/share/classes/sun/security/util/SignatureFileVerifier.java @@ -380,8 +380,9 @@ public class SignatureFileVerifier { 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(); } } diff --git a/src/share/classes/sun/security/x509/CertificateExtensions.java b/src/share/classes/sun/security/x509/CertificateExtensions.java index 75d5ae35b..e93714eaa 100644 --- a/src/share/classes/sun/security/x509/CertificateExtensions.java +++ b/src/share/classes/sun/security/x509/CertificateExtensions.java @@ -124,7 +124,8 @@ public class CertificateExtensions implements CertAttrSet { 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())); diff --git a/src/share/classes/sun/security/x509/X509Key.java b/src/share/classes/sun/security/x509/X509Key.java index 789b7b8dc..c7621d839 100644 --- a/src/share/classes/sun/security/x509/X509Key.java +++ b/src/share/classes/sun/security/x509/X509Key.java @@ -393,7 +393,6 @@ public class X509Key implements PublicKey { throw new InvalidKeyException ("excess key data"); } catch (IOException e) { - // e.printStackTrace (); throw new InvalidKeyException("IOException: " + e.getMessage()); } -- GitLab