Update exception variable names
Consistently use `ex` for caught exception and `cause` for Exception constructor arguments. Issue gh-8945
This commit is contained in:
+2
-2
@@ -107,8 +107,8 @@ public class Argon2PasswordEncoder implements PasswordEncoder {
|
||||
try {
|
||||
decoded = Argon2EncodingUtils.decode(encodedPassword);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
this.logger.warn("Malformed password hash", e);
|
||||
catch (IllegalArgumentException ex) {
|
||||
this.logger.warn("Malformed password hash", ex);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ public final class Base64 {
|
||||
try {
|
||||
decode(bytes);
|
||||
}
|
||||
catch (InvalidBase64CharacterException e) {
|
||||
catch (InvalidBase64CharacterException ex) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -43,8 +43,8 @@ public final class Utf8 {
|
||||
|
||||
return bytesCopy;
|
||||
}
|
||||
catch (CharacterCodingException e) {
|
||||
throw new IllegalArgumentException("Encoding failed", e);
|
||||
catch (CharacterCodingException ex) {
|
||||
throw new IllegalArgumentException("Encoding failed", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ public final class Utf8 {
|
||||
try {
|
||||
return CHARSET.newDecoder().decode(ByteBuffer.wrap(bytes)).toString();
|
||||
}
|
||||
catch (CharacterCodingException e) {
|
||||
throw new IllegalArgumentException("Decoding failed", e);
|
||||
catch (CharacterCodingException ex) {
|
||||
throw new IllegalArgumentException("Decoding failed", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -74,8 +74,8 @@ public class BouncyCastleAesCbcBytesEncryptor extends BouncyCastleAesBytesEncryp
|
||||
try {
|
||||
bytesWritten += blockCipher.doFinal(buf, bytesWritten);
|
||||
}
|
||||
catch (InvalidCipherTextException e) {
|
||||
throw new IllegalStateException("unable to encrypt/decrypt", e);
|
||||
catch (InvalidCipherTextException ex) {
|
||||
throw new IllegalStateException("unable to encrypt/decrypt", ex);
|
||||
}
|
||||
if (bytesWritten == buf.length) {
|
||||
return buf;
|
||||
|
||||
+2
-2
@@ -71,8 +71,8 @@ public class BouncyCastleAesGcmBytesEncryptor extends BouncyCastleAesBytesEncryp
|
||||
try {
|
||||
bytesWritten += blockCipher.doFinal(buf, bytesWritten);
|
||||
}
|
||||
catch (InvalidCipherTextException e) {
|
||||
throw new IllegalStateException("unable to encrypt/decrypt", e);
|
||||
catch (InvalidCipherTextException ex) {
|
||||
throw new IllegalStateException("unable to encrypt/decrypt", ex);
|
||||
}
|
||||
if (bytesWritten == buf.length) {
|
||||
return buf;
|
||||
|
||||
@@ -56,11 +56,11 @@ final class CipherUtils {
|
||||
SecretKeyFactory factory = SecretKeyFactory.getInstance(algorithm);
|
||||
return factory.generateSecret(keySpec);
|
||||
}
|
||||
catch (NoSuchAlgorithmException e) {
|
||||
throw new IllegalArgumentException("Not a valid encryption algorithm", e);
|
||||
catch (NoSuchAlgorithmException ex) {
|
||||
throw new IllegalArgumentException("Not a valid encryption algorithm", ex);
|
||||
}
|
||||
catch (InvalidKeySpecException e) {
|
||||
throw new IllegalArgumentException("Not a valid secret key", e);
|
||||
catch (InvalidKeySpecException ex) {
|
||||
throw new IllegalArgumentException("Not a valid secret key", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,11 +71,11 @@ final class CipherUtils {
|
||||
try {
|
||||
return Cipher.getInstance(algorithm);
|
||||
}
|
||||
catch (NoSuchAlgorithmException e) {
|
||||
throw new IllegalArgumentException("Not a valid encryption algorithm", e);
|
||||
catch (NoSuchAlgorithmException ex) {
|
||||
throw new IllegalArgumentException("Not a valid encryption algorithm", ex);
|
||||
}
|
||||
catch (NoSuchPaddingException e) {
|
||||
throw new IllegalStateException("Should not happen", e);
|
||||
catch (NoSuchPaddingException ex) {
|
||||
throw new IllegalStateException("Should not happen", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,8 +86,8 @@ final class CipherUtils {
|
||||
try {
|
||||
return cipher.getParameters().getParameterSpec(parameterSpecClass);
|
||||
}
|
||||
catch (InvalidParameterSpecException e) {
|
||||
throw new IllegalArgumentException("Unable to access parameter", e);
|
||||
catch (InvalidParameterSpecException ex) {
|
||||
throw new IllegalArgumentException("Unable to access parameter", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,11 +117,11 @@ final class CipherUtils {
|
||||
cipher.init(mode, secretKey);
|
||||
}
|
||||
}
|
||||
catch (InvalidKeyException e) {
|
||||
throw new IllegalArgumentException("Unable to initialize due to invalid secret key", e);
|
||||
catch (InvalidKeyException ex) {
|
||||
throw new IllegalArgumentException("Unable to initialize due to invalid secret key", ex);
|
||||
}
|
||||
catch (InvalidAlgorithmParameterException e) {
|
||||
throw new IllegalStateException("Unable to initialize due to invalid decryption parameter spec", e);
|
||||
catch (InvalidAlgorithmParameterException ex) {
|
||||
throw new IllegalStateException("Unable to initialize due to invalid decryption parameter spec", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,11 +133,11 @@ final class CipherUtils {
|
||||
try {
|
||||
return cipher.doFinal(input);
|
||||
}
|
||||
catch (IllegalBlockSizeException e) {
|
||||
throw new IllegalStateException("Unable to invoke Cipher due to illegal block size", e);
|
||||
catch (IllegalBlockSizeException ex) {
|
||||
throw new IllegalStateException("Unable to invoke Cipher due to illegal block size", ex);
|
||||
}
|
||||
catch (BadPaddingException e) {
|
||||
throw new IllegalStateException("Unable to invoke Cipher due to bad padding", e);
|
||||
catch (BadPaddingException ex) {
|
||||
throw new IllegalStateException("Unable to invoke Cipher due to bad padding", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,8 +64,8 @@ final class Digester {
|
||||
try {
|
||||
return MessageDigest.getInstance(algorithm);
|
||||
}
|
||||
catch (NoSuchAlgorithmException e) {
|
||||
throw new IllegalStateException("No such hashing algorithm", e);
|
||||
catch (NoSuchAlgorithmException ex) {
|
||||
throw new IllegalStateException("No such hashing algorithm", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ public class LdapShaPasswordEncoder implements PasswordEncoder {
|
||||
sha = MessageDigest.getInstance("SHA");
|
||||
sha.update(Utf8.encode(rawPassword));
|
||||
}
|
||||
catch (java.security.NoSuchAlgorithmException e) {
|
||||
catch (java.security.NoSuchAlgorithmException ex) {
|
||||
throw new IllegalStateException("No SHA implementation available!");
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -112,8 +112,8 @@ public class Pbkdf2PasswordEncoder implements PasswordEncoder {
|
||||
try {
|
||||
SecretKeyFactory.getInstance(algorithmName);
|
||||
}
|
||||
catch (NoSuchAlgorithmException e) {
|
||||
throw new IllegalArgumentException("Invalid algorithm '" + algorithmName + "'.", e);
|
||||
catch (NoSuchAlgorithmException ex) {
|
||||
throw new IllegalArgumentException("Invalid algorithm '" + algorithmName + "'.", ex);
|
||||
}
|
||||
this.algorithm = algorithmName;
|
||||
}
|
||||
@@ -163,8 +163,8 @@ public class Pbkdf2PasswordEncoder implements PasswordEncoder {
|
||||
SecretKeyFactory skf = SecretKeyFactory.getInstance(this.algorithm);
|
||||
return EncodingUtils.concatenate(salt, skf.generateSecret(spec).getEncoded());
|
||||
}
|
||||
catch (GeneralSecurityException e) {
|
||||
throw new IllegalStateException("Could not create hash", e);
|
||||
catch (GeneralSecurityException ex) {
|
||||
throw new IllegalStateException("Could not create hash", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -41,11 +41,11 @@ public class CryptoAssumptions {
|
||||
Cipher.getInstance(cipherAlgorithm.toString());
|
||||
aes256Available = Cipher.getMaxAllowedKeyLength("AES") >= 256;
|
||||
}
|
||||
catch (NoSuchAlgorithmException e) {
|
||||
throw new AssumptionViolatedException(cipherAlgorithm + " not available, skipping test", e);
|
||||
catch (NoSuchAlgorithmException ex) {
|
||||
throw new AssumptionViolatedException(cipherAlgorithm + " not available, skipping test", ex);
|
||||
}
|
||||
catch (NoSuchPaddingException e) {
|
||||
throw new AssumptionViolatedException(cipherAlgorithm + " padding not available, skipping test", e);
|
||||
catch (NoSuchPaddingException ex) {
|
||||
throw new AssumptionViolatedException(cipherAlgorithm + " padding not available, skipping test", ex);
|
||||
}
|
||||
Assume.assumeTrue("AES key length of 256 not allowed, skipping test", aes256Available);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user