Always use 'this.' when accessing fields

Apply an Eclipse cleanup rules to ensure that fields are always accessed
using `this.`. This aligns with the style used by Spring Framework and
helps users quickly see the difference between a local and member
variable.

Issue gh-8945
This commit is contained in:
Phillip Webb
2020-07-26 11:51:05 -07:00
committed by Rob Winch
parent 6894ff5d12
commit 8866fa6fb0
793 changed files with 8689 additions and 8459 deletions

View File

@@ -48,7 +48,7 @@ public class HttpNamespaceWithMultipleInterceptorsTests {
request.setServletPath("/somefile.html");
request.setSession(createAuthenticatedSession("ROLE_0", "ROLE_1", "ROLE_2"));
MockHttpServletResponse response = new MockHttpServletResponse();
fcp.doFilter(request, response, new MockFilterChain());
this.fcp.doFilter(request, response, new MockFilterChain());
assertThat(response.getStatus()).isEqualTo(200);
}
@@ -60,7 +60,7 @@ public class HttpNamespaceWithMultipleInterceptorsTests {
request.setServletPath("/secure/somefile.html");
request.setSession(createAuthenticatedSession("ROLE_0"));
MockHttpServletResponse response = new MockHttpServletResponse();
fcp.doFilter(request, response, new MockFilterChain());
this.fcp.doFilter(request, response, new MockFilterChain());
assertThat(response.getStatus()).isEqualTo(403);
}

View File

@@ -48,7 +48,7 @@ public class HttpPathParameterStrippingTests {
request.setPathInfo("/secured;x=y/admin.html");
request.setSession(createAuthenticatedSession("ROLE_USER"));
MockHttpServletResponse response = new MockHttpServletResponse();
fcp.doFilter(request, response, new MockFilterChain());
this.fcp.doFilter(request, response, new MockFilterChain());
}
@Test(expected = RequestRejectedException.class)
@@ -57,7 +57,7 @@ public class HttpPathParameterStrippingTests {
request.setServletPath("/secured/admin.html;x=user.html");
request.setSession(createAuthenticatedSession("ROLE_USER"));
MockHttpServletResponse response = new MockHttpServletResponse();
fcp.doFilter(request, response, new MockFilterChain());
this.fcp.doFilter(request, response, new MockFilterChain());
}
@Test(expected = RequestRejectedException.class)
@@ -67,7 +67,7 @@ public class HttpPathParameterStrippingTests {
request.setPathInfo("/admin.html;x=user.html");
request.setSession(createAuthenticatedSession("ROLE_USER"));
MockHttpServletResponse response = new MockHttpServletResponse();
fcp.doFilter(request, response, new MockFilterChain());
this.fcp.doFilter(request, response, new MockFilterChain());
assertThat(response.getStatus()).isEqualTo(403);
}

View File

@@ -58,50 +58,50 @@ public class MultiAnnotationTests {
@Test(expected = AccessDeniedException.class)
public void preAuthorizeDeniedIsDenied() {
SecurityContextHolder.getContext().setAuthentication(joe_a);
service.preAuthorizeDenyAllMethod();
SecurityContextHolder.getContext().setAuthentication(this.joe_a);
this.service.preAuthorizeDenyAllMethod();
}
@Test(expected = AccessDeniedException.class)
public void preAuthorizeRoleAIsDeniedIfRoleMissing() {
SecurityContextHolder.getContext().setAuthentication(joe_b);
service.preAuthorizeHasRoleAMethod();
SecurityContextHolder.getContext().setAuthentication(this.joe_b);
this.service.preAuthorizeHasRoleAMethod();
}
@Test
public void preAuthorizeRoleAIsAllowedIfRolePresent() {
SecurityContextHolder.getContext().setAuthentication(joe_a);
service.preAuthorizeHasRoleAMethod();
SecurityContextHolder.getContext().setAuthentication(this.joe_a);
this.service.preAuthorizeHasRoleAMethod();
}
@Test
public void securedAnonymousIsAllowed() {
SecurityContextHolder.getContext().setAuthentication(joe_a);
service.securedAnonymousMethod();
SecurityContextHolder.getContext().setAuthentication(this.joe_a);
this.service.securedAnonymousMethod();
}
@Test(expected = AccessDeniedException.class)
public void securedRoleAIsDeniedIfRoleMissing() {
SecurityContextHolder.getContext().setAuthentication(joe_b);
service.securedRoleAMethod();
SecurityContextHolder.getContext().setAuthentication(this.joe_b);
this.service.securedRoleAMethod();
}
@Test
public void securedRoleAIsAllowedIfRolePresent() {
SecurityContextHolder.getContext().setAuthentication(joe_a);
service.securedRoleAMethod();
SecurityContextHolder.getContext().setAuthentication(this.joe_a);
this.service.securedRoleAMethod();
}
@Test(expected = AccessDeniedException.class)
public void preAuthorizedOnlyServiceDeniesIfRoleMissing() {
SecurityContextHolder.getContext().setAuthentication(joe_b);
preService.preAuthorizedMethod();
SecurityContextHolder.getContext().setAuthentication(this.joe_b);
this.preService.preAuthorizedMethod();
}
@Test(expected = AccessDeniedException.class)
public void securedOnlyRoleAServiceDeniesIfRoleMissing() {
SecurityContextHolder.getContext().setAuthentication(joe_b);
secService.securedMethod();
SecurityContextHolder.getContext().setAuthentication(this.joe_b);
this.secService.securedMethod();
}
}

View File

@@ -34,7 +34,7 @@ public class SEC933ApplicationContextTests {
@Test
public void testSimpleApplicationContextBootstrap() {
assertThat(userDetailsService).isNotNull();
assertThat(this.userDetailsService).isNotNull();
}
}

View File

@@ -44,7 +44,7 @@ public class SEC936ApplicationContextTests {
public void securityInterceptorHandlesCallWithNoTargetObject() {
SecurityContextHolder.getContext()
.setAuthentication(new UsernamePasswordAuthenticationToken("bob", "bobspassword"));
sessionRegistry.getAllPrincipals();
this.sessionRegistry.getAllPrincipals();
}
}

View File

@@ -37,7 +37,7 @@ public class PythonInterpreterBasedSecurityTests {
.setAuthentication(new UsernamePasswordAuthenticationToken("bob", "bobspassword"));
// for (int i=0; i < 1000; i++) {
service.someMethod();
this.service.someMethod();
// }
}

View File

@@ -72,9 +72,9 @@ public class FilterChainPerformanceTests {
@Before
public void createAuthenticatedSession() {
session = new MockHttpSession();
SecurityContextHolder.getContext().setAuthentication(user);
session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
this.session = new MockHttpSession();
SecurityContextHolder.getContext().setAuthentication(this.user);
this.session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
SecurityContextHolder.getContext());
SecurityContextHolder.clearContext();
}
@@ -91,7 +91,7 @@ public class FilterChainPerformanceTests {
private MockHttpServletRequest createRequest(String url) {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setSession(session);
request.setSession(this.session);
request.setServletPath(url);
request.setMethod("GET");
return request;
@@ -101,21 +101,21 @@ public class FilterChainPerformanceTests {
for (int i = 0; i < N_INVOCATIONS; i++) {
MockHttpServletRequest request = createRequest("/somefile.html");
stack.doFilter(request, new MockHttpServletResponse(), new MockFilterChain());
session = request.getSession();
this.session = request.getSession();
}
}
@Test
public void minimalStackInvocation() throws Exception {
sw.start("Run with Minimal Filter Stack");
runWithStack(minimalStack);
runWithStack(this.minimalStack);
sw.stop();
}
@Test
public void fullStackInvocation() throws Exception {
sw.start("Run with Full Filter Stack");
runWithStack(fullStack);
runWithStack(this.fullStack);
sw.stop();
}
@@ -130,11 +130,11 @@ public class FilterChainPerformanceTests {
int nAuthorities = user == 0 ? 1 : user * 10;
SecurityContextHolder.getContext().setAuthentication(
new UsernamePasswordAuthenticationToken("bob", "bobspassword", createRoles(nAuthorities)));
session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
this.session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
SecurityContextHolder.getContext());
SecurityContextHolder.clearContext();
sw.start(nAuthorities + " authorities");
runWithStack(minimalStack);
runWithStack(this.minimalStack);
System.out.println(sw.shortSummary());
sw.stop();
}

View File

@@ -52,7 +52,7 @@ public class ProtectPointcutPerformanceTests implements ApplicationContextAware
sw.start();
for (int i = 0; i < 1000; i++) {
try {
SessionRegistry reg = (SessionRegistry) ctx.getBean("sessionRegistryPrototype");
SessionRegistry reg = (SessionRegistry) this.ctx.getBean("sessionRegistryPrototype");
reg.getAllPrincipals();
fail("Expected AuthenticationCredentialsNotFoundException");
}
@@ -65,7 +65,7 @@ public class ProtectPointcutPerformanceTests implements ApplicationContextAware
}
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
ctx = applicationContext;
this.ctx = applicationContext;
}
}

View File

@@ -68,7 +68,7 @@ public class PythonInterpreterPreInvocationAdvice implements PreInvocationAuthor
Object[] args = mi.getArguments();
Object targetObject = mi.getThis();
Method method = ClassUtils.getMostSpecificMethod(mi.getMethod(), targetObject.getClass());
String[] paramNames = parameterNameDiscoverer.getParameterNames(method);
String[] paramNames = this.parameterNameDiscoverer.getParameterNames(method);
Map<String, Object> argMap = new HashMap<>();
for (int i = 0; i < args.length; i++) {

View File

@@ -30,7 +30,7 @@ public class PythonInterpreterPreInvocationAttribute implements PreInvocationAtt
}
public String getScript() {
return script;
return this.script;
}
}