Update exception variable names

Consistently use `ex` for caught exception and `cause` for Exception
constructor arguments.

Issue gh-8945
This commit is contained in:
Phillip Webb
2020-07-28 23:53:30 -07:00
committed by Rob Winch
parent e9130489a6
commit 8d80166aaf
194 changed files with 635 additions and 633 deletions

View File

@@ -62,8 +62,8 @@ public class InvalidConfigurationTests {
setContext("<http auto-config='true' />");
fail();
}
catch (BeanCreationException e) {
Throwable cause = ultimateCause(e);
catch (BeanCreationException ex) {
Throwable cause = ultimateCause(ex);
assertThat(cause instanceof NoSuchBeanDefinitionException).isTrue();
NoSuchBeanDefinitionException nsbe = (NoSuchBeanDefinitionException) cause;
assertThat(nsbe.getBeanName()).isEqualTo(BeanIds.AUTHENTICATION_MANAGER);
@@ -71,11 +71,11 @@ public class InvalidConfigurationTests {
}
}
private Throwable ultimateCause(Throwable e) {
if (e.getCause() == null) {
return e;
private Throwable ultimateCause(Throwable ex) {
if (ex.getCause() == null) {
return ex;
}
return ultimateCause(e.getCause());
return ultimateCause(ex.getCause());
}
private void setContext(String context) {

View File

@@ -113,7 +113,7 @@ public class GlobalMethodSecurityConfigurationTests {
try {
this.authenticationManager.authenticate(new UsernamePasswordAuthenticationToken("foo", "bar"));
}
catch (AuthenticationException e) {
catch (AuthenticationException ex) {
}
assertThat(this.events.getEvents()).extracting(Object::getClass)

View File

@@ -120,8 +120,8 @@ public class NamespaceHttpX509Tests {
CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
return (T) certFactory.generateCertificate(is);
}
catch (Exception e) {
throw new IllegalArgumentException(e);
catch (Exception ex) {
throw new IllegalArgumentException(ex);
}
}
@@ -244,8 +244,8 @@ public class NamespaceHttpX509Tests {
try {
return ((X500Name) certificate.getSubjectDN()).getCommonName();
}
catch (Exception e) {
throw new IllegalArgumentException(e);
catch (Exception ex) {
throw new IllegalArgumentException(ex);
}
}

View File

@@ -209,8 +209,8 @@ public class ServletApiConfigurerTests {
try {
return (T) FieldUtils.getFieldValue(target, fieldName);
}
catch (Exception e) {
throw new RuntimeException(e);
catch (Exception ex) {
throw new RuntimeException(ex);
}
}

View File

@@ -94,8 +94,8 @@ public class X509ConfigurerTests {
CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
return (T) certFactory.generateCertificate(is);
}
catch (Exception e) {
throw new IllegalArgumentException(e);
catch (Exception ex) {
throw new IllegalArgumentException(ex);
}
}

View File

@@ -256,8 +256,8 @@ public class Saml2LoginConfigurerTests {
iout.finish();
return new String(out.toByteArray(), StandardCharsets.UTF_8);
}
catch (IOException e) {
throw new Saml2Exception("Unable to inflate string", e);
catch (IOException ex) {
throw new Saml2Exception("Unable to inflate string", ex);
}
}

View File

@@ -64,8 +64,8 @@ public class TestSaml2Credentials {
return (X509Certificate) factory
.generateCertificate(new ByteArrayInputStream(source.getBytes(StandardCharsets.UTF_8)));
}
catch (Exception e) {
throw new IllegalArgumentException(e);
catch (Exception ex) {
throw new IllegalArgumentException(ex);
}
}

View File

@@ -42,8 +42,8 @@ public class XmlParser implements AutoCloseable {
return new XmlNode(dBuilder.parse(this.xml));
}
catch (IOException | ParserConfigurationException | SAXException e) {
throw new IllegalStateException(e);
catch (IOException | ParserConfigurationException | SAXException ex) {
throw new IllegalStateException(ex);
}
}

View File

@@ -418,8 +418,8 @@ public class SessionManagementConfigTests {
try {
return (T) FieldUtils.getFieldValue(target, fieldName);
}
catch (Exception e) {
throw new RuntimeException(e);
catch (Exception ex) {
throw new RuntimeException(ex);
}
}

View File

@@ -65,7 +65,7 @@ public class SpringTestContext implements Closeable {
try {
this.context.close();
}
catch (Exception e) {
catch (Exception ex) {
}
}

View File

@@ -447,8 +447,8 @@ public class OAuth2ResourceServerSpecTests {
KeyFactory factory = KeyFactory.getInstance("RSA");
rsaPublicKey = (RSAPublicKey) factory.generatePublic(spec);
}
catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
e.printStackTrace();
catch (NoSuchAlgorithmException | InvalidKeySpecException ex) {
ex.printStackTrace();
}
return rsaPublicKey;
}

View File

@@ -470,7 +470,7 @@ public class ServerHttpSecurityTests {
Object converter = ReflectionTestUtils.getField(filter, "authenticationConverter");
return converter.getClass().isAssignableFrom(ServerX509AuthenticationConverter.class);
}
catch (IllegalArgumentException e) {
catch (IllegalArgumentException ex) {
// field doesn't exist
return false;
}