Update exception variable names
Consistently use `ex` for caught exception and `cause` for Exception constructor arguments. Issue gh-8945
This commit is contained in:
@@ -102,8 +102,8 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
|
||||
try {
|
||||
return build();
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.debug("Failed to perform build. Returning null", e);
|
||||
catch (Exception ex) {
|
||||
this.logger.debug("Failed to perform build. Returning null", ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -595,7 +595,7 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
|
||||
try (ServerSocket serverSocket = new ServerSocket(DEFAULT_PORT)) {
|
||||
return serverSocket.getLocalPort();
|
||||
}
|
||||
catch (IOException e) {
|
||||
catch (IOException ex) {
|
||||
return RANDOM_PORT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,9 +63,9 @@ final class AutowireBeanFactoryObjectPostProcessor
|
||||
try {
|
||||
result = (T) this.autowireBeanFactory.initializeBean(object, object.toString());
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
catch (RuntimeException ex) {
|
||||
Class<?> type = object.getClass();
|
||||
throw new RuntimeException("Could not postProcess " + object + " of type " + type, e);
|
||||
throw new RuntimeException("Could not postProcess " + object + " of type " + type, ex);
|
||||
}
|
||||
this.autowireBeanFactory.autowireBean(object);
|
||||
if (result instanceof DisposableBean) {
|
||||
|
||||
@@ -153,8 +153,8 @@ public class GlobalMethodSecurityConfiguration implements ImportAware, SmartInit
|
||||
try {
|
||||
initializeMethodSecurityInterceptor();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
PermissionEvaluator permissionEvaluator = getSingleBeanOrNull(PermissionEvaluator.class);
|
||||
@@ -182,7 +182,7 @@ public class GlobalMethodSecurityConfiguration implements ImportAware, SmartInit
|
||||
try {
|
||||
return this.context.getBean(type);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException e) {
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -311,26 +311,26 @@ public final class WebSecurity extends AbstractConfiguredSecurityBuilder<Filter,
|
||||
try {
|
||||
this.defaultWebSecurityExpressionHandler.setRoleHierarchy(applicationContext.getBean(RoleHierarchy.class));
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException e) {
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
}
|
||||
|
||||
try {
|
||||
this.defaultWebSecurityExpressionHandler
|
||||
.setPermissionEvaluator(applicationContext.getBean(PermissionEvaluator.class));
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException e) {
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
}
|
||||
|
||||
this.ignoredRequestRegistry = new IgnoredRequestConfigurer(applicationContext);
|
||||
try {
|
||||
this.httpFirewall = applicationContext.getBean(HttpFirewall.class);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException e) {
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
}
|
||||
try {
|
||||
this.requestRejectedHandler = applicationContext.getBean(RequestRejectedHandler.class);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException e) {
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -165,8 +165,8 @@ class SecurityReactorContextConfiguration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable t) {
|
||||
this.delegate.onError(t);
|
||||
public void onError(Throwable ex) {
|
||||
this.delegate.onError(ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -136,7 +136,7 @@ public final class RequestCacheConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
try {
|
||||
return context.getBean(type);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException e) {
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,7 +560,7 @@ public final class SessionManagementConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
try {
|
||||
return context.getBean(type);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException e) {
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,7 +506,7 @@ public final class OAuth2ResourceServerConfigurer<H extends HttpSecurityBuilder<
|
||||
try {
|
||||
return this.bearerTokenResolver.resolve(request) != null;
|
||||
}
|
||||
catch (OAuth2AuthenticationException e) {
|
||||
catch (OAuth2AuthenticationException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ public final class Saml2LoginConfigurer<B extends HttpSecurityBuilder<B>>
|
||||
try {
|
||||
return context.getBean(clazz);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException e) {
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public abstract class AbstractSecurityWebSocketMessageBrokerConfigurer extends A
|
||||
try {
|
||||
return this.context.getBean(SimpAnnotationMethodMessageHandler.class).getPathMatcher();
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException e) {
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
return new AntPathMatcher();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,9 +51,9 @@ public class AuthenticationManagerFactoryBean implements FactoryBean<Authenticat
|
||||
try {
|
||||
return (AuthenticationManager) this.bf.getBean(BeanIds.AUTHENTICATION_MANAGER);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException e) {
|
||||
if (!BeanIds.AUTHENTICATION_MANAGER.equals(e.getBeanName())) {
|
||||
throw e;
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
if (!BeanIds.AUTHENTICATION_MANAGER.equals(ex.getBeanName())) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
UserDetailsService uds = getBeanOrNull(UserDetailsService.class);
|
||||
|
||||
@@ -118,7 +118,7 @@ public class UserServiceBeanDefinitionParser extends AbstractUserDetailsServiceB
|
||||
try {
|
||||
this.random = SecureRandom.getInstance("SHA1PRNG");
|
||||
}
|
||||
catch (NoSuchAlgorithmException e) {
|
||||
catch (NoSuchAlgorithmException ex) {
|
||||
// Shouldn't happen...
|
||||
throw new RuntimeException("Failed find SHA1PRNG algorithm!");
|
||||
}
|
||||
|
||||
@@ -113,8 +113,8 @@ public class RsaKeyConversionServicePostProcessor implements BeanFactoryPostProc
|
||||
try {
|
||||
return resource.getInputStream();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
catch (IOException ex) {
|
||||
throw new UncheckedIOException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,8 +123,8 @@ public class RsaKeyConversionServicePostProcessor implements BeanFactoryPostProc
|
||||
try (InputStream is = inputStream) {
|
||||
return inputStreamKeyConverter.convert(is);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
catch (IOException ex) {
|
||||
throw new UncheckedIOException(ex);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public class DefaultFilterChainValidator implements FilterChainProxy.FilterChain
|
||||
try {
|
||||
filters = fcp.getFilters(loginPage);
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception ex) {
|
||||
// May happen legitimately if a filter-chain request matcher requires more
|
||||
// request data than that provided
|
||||
// by the dummy request used when creating the filter invocation.
|
||||
@@ -196,19 +196,19 @@ public class DefaultFilterChainValidator implements FilterChainProxy.FilterChain
|
||||
try {
|
||||
fsi.getAccessDecisionManager().decide(token, loginRequest, attributes);
|
||||
}
|
||||
catch (AccessDeniedException e) {
|
||||
catch (AccessDeniedException ex) {
|
||||
this.logger
|
||||
.warn("Anonymous access to the login page doesn't appear to be enabled. This is almost certainly "
|
||||
+ "an error. Please check your configuration allows unauthenticated access to the configured "
|
||||
+ "login page. (Simulated access was rejected: " + e + ")");
|
||||
+ "login page. (Simulated access was rejected: " + ex + ")");
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception ex) {
|
||||
// May happen legitimately if a filter-chain request matcher requires more
|
||||
// request data than that provided
|
||||
// by the dummy request used when creating the filter invocation. See SEC-1878
|
||||
this.logger.info(
|
||||
"Unable to check access to the login page to determine if anonymous access is allowed. This might be an error, but can happen under normal circumstances.",
|
||||
e);
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -478,9 +478,9 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||
try {
|
||||
builder.addConstructorArgValue(new StaticAllowFromStrategy(new URI(value)));
|
||||
}
|
||||
catch (URISyntaxException e) {
|
||||
catch (URISyntaxException ex) {
|
||||
parserContext.getReaderContext().error("'value' attribute doesn't represent a valid URI.", frameElement,
|
||||
e);
|
||||
ex);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ final class OAuth2ResourceServerBeanDefinitionParser implements BeanDefinitionPa
|
||||
try {
|
||||
return this.bearerTokenResolver.resolve(request) != null;
|
||||
}
|
||||
catch (OAuth2AuthenticationException e) {
|
||||
catch (OAuth2AuthenticationException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,10 +52,10 @@ class ContextSourceSettingPostProcessor implements BeanFactoryPostProcessor, Ord
|
||||
contextSourceClass = ClassUtils.forName(REQUIRED_CONTEXT_SOURCE_CLASS_NAME,
|
||||
ClassUtils.getDefaultClassLoader());
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
catch (ClassNotFoundException ex) {
|
||||
throw new ApplicationContextException("Couldn't locate: " + REQUIRED_CONTEXT_SOURCE_CLASS_NAME + ". "
|
||||
+ " If you are using LDAP with Spring Security, please ensure that you include the spring-ldap "
|
||||
+ "jar file in your application", e);
|
||||
+ "jar file in your application", ex);
|
||||
}
|
||||
|
||||
String[] sources = bf.getBeanNamesForType(contextSourceClass, false, false);
|
||||
|
||||
@@ -221,7 +221,7 @@ public class LdapServerBeanDefinitionParser implements BeanDefinitionParser {
|
||||
try (ServerSocket serverSocket = new ServerSocket(DEFAULT_PORT)) {
|
||||
return String.valueOf(serverSocket.getLocalPort());
|
||||
}
|
||||
catch (IOException e) {
|
||||
catch (IOException ex) {
|
||||
return RANDOM_PORT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,12 +489,12 @@ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionP
|
||||
try {
|
||||
this.delegate = this.beanFactory.getBean(this.authMgrBean, AuthenticationManager.class);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException e) {
|
||||
if (BeanIds.AUTHENTICATION_MANAGER.equals(e.getBeanName())) {
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
if (BeanIds.AUTHENTICATION_MANAGER.equals(ex.getBeanName())) {
|
||||
throw new NoSuchBeanDefinitionException(BeanIds.AUTHENTICATION_MANAGER,
|
||||
AuthenticationManagerFactoryBean.MISSING_BEAN_ERROR_MESSAGE);
|
||||
}
|
||||
throw e;
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,8 +122,8 @@ final class ProtectPointcutPostProcessor implements BeanPostProcessor {
|
||||
try {
|
||||
methods = bean.getClass().getMethods();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(e.getMessage());
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException(ex.getMessage());
|
||||
}
|
||||
|
||||
// Check to see if any of those methods are compatible with our pointcut
|
||||
|
||||
@@ -1426,8 +1426,8 @@ public class ServerHttpSecurity {
|
||||
return writer.toString();
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public class SpringTestContext implements Closeable {
|
||||
try {
|
||||
this.context.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user