Skip to content

Commit

Permalink
8282632: Cleanup unnecessary calls to Throwable.initCause() in java.s…
Browse files Browse the repository at this point in the history
…ecurity.jgss

Reviewed-by: mullan, rhalade
  • Loading branch information
Andrey Turbanov committed Mar 7, 2022
1 parent ccad392 commit 50eb915
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -127,9 +127,7 @@ public NegotiatorImpl(HttpCallerInfo hci) throws IOException {
"fallback to other scheme if allowed. Reason:");
e.printStackTrace();
}
IOException ioe = new IOException("Negotiate support not initiated");
ioe.initCause(e);
throw ioe;
throw new IOException("Negotiate support not initiated", e);
}
}

Expand Down Expand Up @@ -157,9 +155,7 @@ public byte[] nextToken(byte[] token) throws IOException {
System.out.println("Negotiate support cannot continue. Reason:");
e.printStackTrace();
}
IOException ioe = new IOException("Negotiate support cannot continue");
ioe.initCause(e);
throw ioe;
throw new IOException("Negotiate support cannot continue", e);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -234,10 +234,8 @@ private void parseEData(byte[] data) throws IOException {
System.out.println("Unable to parse eData field of KRB-ERROR:\n" +
new sun.security.util.HexDumpEncoder().encodeBuffer(data));
}
IOException ioe = new IOException(
"Unable to parse eData field of KRB-ERROR");
ioe.initCause(e);
throw ioe;
throw new IOException(
"Unable to parse eData field of KRB-ERROR", e);
}
} else {
if (DEBUG) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,7 +29,6 @@
import javax.crypto.*;
import javax.crypto.spec.*;
import java.util.*;
import sun.security.krb5.EncryptedData;
import sun.security.krb5.KrbCryptoException;
import sun.security.krb5.Confounder;
import sun.security.krb5.internal.crypto.KeyUsage;
Expand Down Expand Up @@ -159,10 +158,7 @@ public byte[] calculateChecksum(byte[] baseKey, int usage, byte[] input,
System.arraycopy(ss, 0, new_ss, 0, ss.length);
Ksign = getHmac(baseKey, new_ss);
} catch (Exception e) {
GeneralSecurityException gse =
new GeneralSecurityException("Calculate Checkum Failed!");
gse.initCause(e);
throw gse;
throw new GeneralSecurityException("Calculate Checksum Failed!", e);
}

// get the salt using key usage
Expand All @@ -173,10 +169,7 @@ public byte[] calculateChecksum(byte[] baseKey, int usage, byte[] input,
try {
messageDigest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
GeneralSecurityException gse =
new GeneralSecurityException("Calculate Checkum Failed!");
gse.initCause(e);
throw gse;
throw new GeneralSecurityException("Calculate Checksum Failed!", e);
}
messageDigest.update(salt);
messageDigest.update(input, start, len);
Expand Down

1 comment on commit 50eb915

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.