Skip to content

Commit

Permalink
Update exception variable names
Browse files Browse the repository at this point in the history
Consistently use `ex` for caught exception and `cause` for Exception
constructor arguments.

Issue spring-projectsgh-8945
  • Loading branch information
philwebb authored and rwinch committed Aug 24, 2020
1 parent e913048 commit 8d80166
Show file tree
Hide file tree
Showing 194 changed files with 635 additions and 633 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public IdentityUnavailableException(String msg) {
* Constructs an <code>IdentityUnavailableException</code> with the specified message
* and root cause.
* @param msg the detail message
* @param t root cause
* @param cause root cause
*/
public IdentityUnavailableException(String msg, Throwable t) {
super(msg, t);
public IdentityUnavailableException(String msg, Throwable cause) {
super(msg, cause);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public ObjectIdentityImpl(Object object) throws IdentityUnavailableException {
Method method = typeClass.getMethod("getId", new Class[] {});
result = method.invoke(object);
}
catch (Exception e) {
throw new IdentityUnavailableException("Could not extract identity from object " + object, e);
catch (Exception ex) {
throw new IdentityUnavailableException("Could not extract identity from object " + object, ex);
}

Assert.notNull(result, "getId() is required to return a non-null value");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ private boolean hasValidClassIdType(ResultSet resultSet) {
try {
hasClassIdType = classIdTypeFrom(resultSet) != null;
}
catch (SQLException e) {
log.debug("Unable to obtain the class id type", e);
catch (SQLException ex) {
log.debug("Unable to obtain the class id type", ex);
}
return hasClassIdType;
}
Expand All @@ -101,8 +101,8 @@ private <T extends Serializable> Class<T> classIdTypeFrom(String className) {
try {
targetType = Class.forName(className);
}
catch (ClassNotFoundException e) {
log.debug("Unable to find class id type on classpath", e);
catch (ClassNotFoundException ex) {
log.debug("Unable to find class id type on classpath", ex);
}
}
return targetType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,26 +194,26 @@ private List<AccessControlEntryImpl> readAces(AclImpl acl) {
try {
return (List<AccessControlEntryImpl>) this.fieldAces.get(acl);
}
catch (IllegalAccessException e) {
throw new IllegalStateException("Could not obtain AclImpl.aces field", e);
catch (IllegalAccessException ex) {
throw new IllegalStateException("Could not obtain AclImpl.aces field", ex);
}
}

private void setAclOnAce(AccessControlEntryImpl ace, AclImpl acl) {
try {
this.fieldAcl.set(ace, acl);
}
catch (IllegalAccessException e) {
throw new IllegalStateException("Could not or set AclImpl on AccessControlEntryImpl fields", e);
catch (IllegalAccessException ex) {
throw new IllegalStateException("Could not or set AclImpl on AccessControlEntryImpl fields", ex);
}
}

private void setAces(AclImpl acl, List<AccessControlEntryImpl> aces) {
try {
this.fieldAces.set(acl, aces);
}
catch (IllegalAccessException e) {
throw new IllegalStateException("Could not set AclImpl entries", e);
catch (IllegalAccessException ex) {
throw new IllegalStateException("Could not set AclImpl entries", ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public AlreadyExistsException(String msg) {
* Constructs an <code>AlreadyExistsException</code> with the specified message and
* root cause.
* @param msg the detail message
* @param t root cause
* @param cause root cause
*/
public AlreadyExistsException(String msg, Throwable t) {
super(msg, t);
public AlreadyExistsException(String msg, Throwable cause) {
super(msg, cause);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public ChildrenExistException(String msg) {
* Constructs an <code>ChildrenExistException</code> with the specified message and
* root cause.
* @param msg the detail message
* @param t root cause
* @param cause root cause
*/
public ChildrenExistException(String msg, Throwable t) {
super(msg, t);
public ChildrenExistException(String msg, Throwable cause) {
super(msg, cause);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public NotFoundException(String msg) {
* Constructs an <code>NotFoundException</code> with the specified message and root
* cause.
* @param msg the detail message
* @param t root cause
* @param cause root cause
*/
public NotFoundException(String msg, Throwable t) {
super(msg, t);
public NotFoundException(String msg, Throwable cause) {
super(msg, cause);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public UnloadedSidException(String msg) {
* Constructs an <code>NotFoundException</code> with the specified message and root
* cause.
* @param msg the detail message
* @param t root cause
* @param cause root cause
*/
public UnloadedSidException(String msg, Throwable t) {
super(msg, t);
public UnloadedSidException(String msg, Throwable cause) {
super(msg, cause);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@ public MutableAcl updateAcl(MutableAcl acl) throws NotFoundException {
((AuditableAccessControlEntry) ac).isAuditFailure()));
}
}
catch (IllegalAccessException e) {
e.printStackTrace();
catch (IllegalAccessException ex) {
ex.printStackTrace();
}

return acl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ public void createTables() throws Exception {
// new DatabaseSeeder(dataSource, new
// ClassPathResource("createAclSchemaPostgres.sql"));
}
catch (Exception e) {
e.printStackTrace();
throw e;
catch (Exception ex) {
ex.printStackTrace();
throw ex;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ private CasAuthenticationToken authenticateNow(final Authentication authenticati
return new CasAuthenticationToken(this.key, userDetails, authentication.getCredentials(),
this.authoritiesMapper.mapAuthorities(userDetails.getAuthorities()), userDetails, assertion);
}
catch (final TicketValidationException e) {
throw new BadCredentialsException(e.getMessage(), e);
catch (TicketValidationException ex) {
throw new BadCredentialsException(ex.getMessage(), ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public ServiceAuthenticationDetails buildDetails(HttpServletRequest context) {
return new DefaultServiceAuthenticationDetails(this.serviceProperties.getService(), context,
this.artifactPattern);
}
catch (MalformedURLException e) {
throw new RuntimeException(e);
catch (MalformedURLException ex) {
throw new RuntimeException(ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public O getOrBuild() {
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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ private int getDefaultPort() {
try (ServerSocket serverSocket = new ServerSocket(DEFAULT_PORT)) {
return serverSocket.getLocalPort();
}
catch (IOException e) {
catch (IOException ex) {
return RANDOM_PORT;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public <T> T postProcess(T object) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ public void afterSingletonsInstantiated() {
try {
initializeMethodSecurityInterceptor();
}
catch (Exception e) {
throw new RuntimeException(e);
catch (Exception ex) {
throw new RuntimeException(ex);
}

PermissionEvaluator permissionEvaluator = getSingleBeanOrNull(PermissionEvaluator.class);
Expand Down Expand Up @@ -182,7 +182,7 @@ private <T> T getSingleBeanOrNull(Class<T> type) {
try {
return this.context.getBean(type);
}
catch (NoSuchBeanDefinitionException e) {
catch (NoSuchBeanDefinitionException ex) {
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,26 +311,26 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
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) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ public void onNext(T t) {
}

@Override
public void onError(Throwable t) {
this.delegate.onError(t);
public void onError(Throwable ex) {
this.delegate.onError(ex);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private <T> T getBeanOrNull(Class<T> type) {
try {
return context.getBean(type);
}
catch (NoSuchBeanDefinitionException e) {
catch (NoSuchBeanDefinitionException ex) {
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ private <T> T getBeanOrNull(Class<T> type) {
try {
return context.getBean(type);
}
catch (NoSuchBeanDefinitionException e) {
catch (NoSuchBeanDefinitionException ex) {
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public boolean matches(HttpServletRequest request) {
try {
return this.bearerTokenResolver.resolve(request) != null;
}
catch (OAuth2AuthenticationException e) {
catch (OAuth2AuthenticationException ex) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ private <C> C getBeanOrNull(B http, Class<C> clazz) {
try {
return context.getBean(clazz);
}
catch (NoSuchBeanDefinitionException e) {
catch (NoSuchBeanDefinitionException ex) {
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private PathMatcher getDefaultPathMatcher() {
try {
return this.context.getBean(SimpAnnotationMethodMessageHandler.class).getPathMatcher();
}
catch (NoSuchBeanDefinitionException e) {
catch (NoSuchBeanDefinitionException ex) {
return new AntPathMatcher();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public AuthenticationManager getObject() throws Exception {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private String generateRandomPassword() {
try {
this.random = SecureRandom.getInstance("SHA1PRNG");
}
catch (NoSuchAlgorithmException e) {
catch (NoSuchAlgorithmException ex) {
// Shouldn't happen...
throw new RuntimeException("Failed find SHA1PRNG algorithm!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ private InputStream toInputStream(Resource resource) {
try {
return resource.getInputStream();
}
catch (IOException e) {
throw new UncheckedIOException(e);
catch (IOException ex) {
throw new UncheckedIOException(ex);
}
}

Expand All @@ -123,8 +123,8 @@ private <T> Converter<InputStream, T> autoclose(Converter<InputStream, T> inputS
try (InputStream is = inputStream) {
return inputStreamKeyConverter.convert(is);
}
catch (IOException e) {
throw new UncheckedIOException(e);
catch (IOException ex) {
throw new UncheckedIOException(ex);
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private void checkLoginPageIsntProtected(FilterChainProxy fcp, List<Filter> filt
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.
Expand Down Expand Up @@ -196,19 +196,19 @@ private void checkLoginPageIsntProtected(FilterChainProxy fcp, List<Filter> filt
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);
}
}

Expand Down
Loading

0 comments on commit 8d80166

Please sign in to comment.