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

@@ -117,21 +117,21 @@ public class RoleHierarchyImplTests {
roleHierarchyImpl.setHierarchy("ROLE_A > ROLE_A");
fail("Cycle in role hierarchy was not detected!");
}
catch (CycleInRoleHierarchyException e) {
catch (CycleInRoleHierarchyException ex) {
}
try {
roleHierarchyImpl.setHierarchy("ROLE_A > ROLE_B\nROLE_B > ROLE_A");
fail("Cycle in role hierarchy was not detected!");
}
catch (CycleInRoleHierarchyException e) {
catch (CycleInRoleHierarchyException ex) {
}
try {
roleHierarchyImpl.setHierarchy("ROLE_A > ROLE_B\nROLE_B > ROLE_C\nROLE_C > ROLE_A");
fail("Cycle in role hierarchy was not detected!");
}
catch (CycleInRoleHierarchyException e) {
catch (CycleInRoleHierarchyException ex) {
}
try {
@@ -139,14 +139,14 @@ public class RoleHierarchyImplTests {
"ROLE_A > ROLE_B\nROLE_B > ROLE_C\nROLE_C > ROLE_E\nROLE_E > ROLE_D\nROLE_D > ROLE_B");
fail("Cycle in role hierarchy was not detected!");
}
catch (CycleInRoleHierarchyException e) {
catch (CycleInRoleHierarchyException ex) {
}
try {
roleHierarchyImpl.setHierarchy("ROLE_C > ROLE_B\nROLE_B > ROLE_A\nROLE_A > ROLE_B");
fail("Cycle in role hierarchy was not detected!");
}
catch (CycleInRoleHierarchyException e) {
catch (CycleInRoleHierarchyException ex) {
}
}
@@ -157,7 +157,7 @@ public class RoleHierarchyImplTests {
try {
roleHierarchyImpl.setHierarchy("ROLE_A > ROLE_B\nROLE_A > ROLE_C\nROLE_C > ROLE_D\nROLE_B > ROLE_D");
}
catch (CycleInRoleHierarchyException e) {
catch (CycleInRoleHierarchyException ex) {
fail("A cycle in role hierarchy was incorrectly detected!");
}
}

View File

@@ -271,8 +271,8 @@ public class ProviderManagerTests {
mgr.authenticate(authReq);
fail("Expected exception");
}
catch (BadCredentialsException e) {
assertThat(e).isSameAs(expected);
catch (BadCredentialsException ex) {
assertThat(ex).isSameAs(expected);
}
}
@@ -289,8 +289,8 @@ public class ProviderManagerTests {
mgr.authenticate(authReq);
fail("Expected exception");
}
catch (LockedException e) {
assertThat(e).isSameAs(expected);
catch (LockedException ex) {
assertThat(ex).isSameAs(expected);
}
verify(publisher).publishAuthenticationFailure(expected, authReq);
}
@@ -329,18 +329,18 @@ public class ProviderManagerTests {
childMgr.authenticate(authReq);
fail("Expected exception");
}
catch (BadCredentialsException e) {
assertThat(e).isSameAs(badCredentialsExParent);
catch (BadCredentialsException ex) {
assertThat(ex).isSameAs(badCredentialsExParent);
}
verify(publisher).publishAuthenticationFailure(badCredentialsExParent, authReq); // Parent
// publishes
verifyNoMoreInteractions(publisher); // Child should not publish (duplicate event)
}
private AuthenticationProvider createProviderWhichThrows(final AuthenticationException e) {
private AuthenticationProvider createProviderWhichThrows(final AuthenticationException ex) {
AuthenticationProvider provider = mock(AuthenticationProvider.class);
given(provider.supports(any(Class.class))).willReturn(true);
given(provider.authenticate(any(Authentication.class))).willThrow(e);
given(provider.authenticate(any(Authentication.class))).willThrow(ex);
return provider;
}

View File

@@ -77,7 +77,7 @@ public class JaasAuthenticationProviderTests {
this.jaasProvider.authenticate(new UsernamePasswordAuthenticationToken("user", "asdf"));
fail("LoginException should have been thrown for the bad password");
}
catch (AuthenticationException e) {
catch (AuthenticationException ex) {
}
assertThat(this.eventCheck.failedEvent).as("Failure event not fired").isNotNull();
@@ -92,7 +92,7 @@ public class JaasAuthenticationProviderTests {
this.jaasProvider.authenticate(new UsernamePasswordAuthenticationToken("asdf", "password"));
fail("LoginException should have been thrown for the bad user");
}
catch (AuthenticationException e) {
catch (AuthenticationException ex) {
}
assertThat(this.eventCheck.failedEvent).as("Failure event not fired").isNotNull();
@@ -241,9 +241,9 @@ public class JaasAuthenticationProviderTests {
try {
this.jaasProvider.authenticate(new UsernamePasswordAuthenticationToken("user", "password"));
}
catch (LockedException e) {
catch (LockedException ex) {
}
catch (Exception e) {
catch (Exception ex) {
fail("LockedException should have been thrown and caught");
}
}

View File

@@ -75,7 +75,7 @@ public class SecurityContextLoginModuleTests {
this.module.login();
fail("LoginException expected, there is no Authentication in the SecurityContext");
}
catch (LoginException e) {
catch (LoginException ex) {
}
}
@@ -107,7 +107,7 @@ public class SecurityContextLoginModuleTests {
this.module.login();
fail("LoginException expected, the authentication is null in the SecurityContext");
}
catch (Exception e) {
catch (Exception ex) {
}
}

View File

@@ -63,8 +63,8 @@ public class TestLoginModule implements LoginModule {
this.password = new String(passwordCallback.getPassword());
this.user = nameCallback.getName();
}
catch (Exception e) {
throw new RuntimeException(e);
catch (Exception ex) {
throw new RuntimeException(ex);
}
}

View File

@@ -40,8 +40,8 @@ public class KeyBasedPersistenceTokenServiceTests {
service.setSecureRandom(rnd);
service.afterPropertiesSet();
}
catch (Exception e) {
throw new RuntimeException(e);
catch (Exception ex) {
throw new RuntimeException(ex);
}
return service;
}