Skip to content

Commit 8cc0fa5

Browse files
committed
Polishing
1 parent a3163ce commit 8cc0fa5

File tree

6 files changed

+40
-38
lines changed

6 files changed

+40
-38
lines changed

spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
*/
4949
abstract class AbstractRecursiveAnnotationVisitor extends AnnotationVisitor {
5050

51-
protected final Log logger = LogFactory.getLog(this.getClass());
51+
protected final Log logger = LogFactory.getLog(getClass());
5252

5353
protected final AnnotationAttributes attributes;
5454

@@ -94,10 +94,10 @@ protected Object getEnumValue(String asmTypeDescriptor, String attributeValue) {
9494
}
9595
}
9696
catch (ClassNotFoundException ex) {
97-
this.logger.debug("Failed to classload enum type while reading annotation metadata", ex);
97+
logger.debug("Failed to classload enum type while reading annotation metadata", ex);
9898
}
9999
catch (IllegalAccessException ex) {
100-
this.logger.warn("Could not access enum value while reading annotation metadata", ex);
100+
logger.warn("Could not access enum value while reading annotation metadata", ex);
101101
}
102102
return valueToUse;
103103
}
@@ -169,7 +169,6 @@ class RecursiveAnnotationAttributesVisitor extends AbstractRecursiveAnnotationVi
169169

170170
private final String annotationType;
171171

172-
173172
public RecursiveAnnotationAttributesVisitor(String annotationType, AnnotationAttributes attributes,
174173
ClassLoader classLoader) {
175174
super(classLoader, attributes);
@@ -183,8 +182,8 @@ public final void visitEnd() {
183182
doVisitEnd(annotationClass);
184183
}
185184
catch (ClassNotFoundException ex) {
186-
this.logger.debug("Failed to class-load type while reading annotation metadata. "
187-
+ "This is a non-fatal error, but certain annotation metadata may be unavailable.", ex);
185+
logger.debug("Failed to class-load type while reading annotation metadata. " +
186+
"This is a non-fatal error, but certain annotation metadata may be unavailable.", ex);
188187
}
189188
}
190189

@@ -246,7 +245,6 @@ final class AnnotationAttributesReadingVisitor extends RecursiveAnnotationAttrib
246245

247246
private final Map<String, Set<String>> metaAnnotationMap;
248247

249-
250248
public AnnotationAttributesReadingVisitor(String annotationType,
251249
MultiValueMap<String, AnnotationAttributes> attributesMap, Map<String, Set<String>> metaAnnotationMap,
252250
ClassLoader classLoader) {
@@ -257,7 +255,6 @@ public AnnotationAttributesReadingVisitor(String annotationType,
257255
this.metaAnnotationMap = metaAnnotationMap;
258256
}
259257

260-
261258
@Override
262259
public void doVisitEnd(Class<?> annotationClass) {
263260
super.doVisitEnd(annotationClass);

spring-core/src/main/java/org/springframework/core/type/filter/AbstractClassTestingTypeFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,8 +19,8 @@
1919
import java.io.IOException;
2020

2121
import org.springframework.core.type.ClassMetadata;
22-
import org.springframework.core.type.classreading.MetadataReaderFactory;
2322
import org.springframework.core.type.classreading.MetadataReader;
23+
import org.springframework.core.type.classreading.MetadataReaderFactory;
2424

2525
/**
2626
* Type filter that exposes a

spring-core/src/main/java/org/springframework/core/type/filter/AspectJTypeFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,8 +29,8 @@
2929
import org.aspectj.weaver.patterns.SimpleScope;
3030
import org.aspectj.weaver.patterns.TypePattern;
3131

32-
import org.springframework.core.type.classreading.MetadataReaderFactory;
3332
import org.springframework.core.type.classreading.MetadataReader;
33+
import org.springframework.core.type.classreading.MetadataReaderFactory;
3434

3535
/**
3636
* Type filter that uses AspectJ type pattern for matching.

spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ protected List<HandlerMethodArgumentResolver> initArgumentResolvers() {
310310

311311
resolvers.addAll(getCustomArgumentResolvers());
312312
resolvers.add(new PayloadArgumentResolver(this.messageConverter,
313-
(this.validator != null ? this.validator : new NoopValidator())));
313+
(this.validator != null ? this.validator : new NoOpValidator())));
314314

315315
return resolvers;
316316
}
@@ -458,7 +458,7 @@ protected AbstractExceptionHandlerMethodResolver createExceptionHandlerMethodRes
458458
}
459459

460460

461-
private static final class NoopValidator implements Validator {
461+
private static final class NoOpValidator implements Validator {
462462

463463
@Override
464464
public boolean supports(Class<?> clazz) {

spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import org.springframework.mock.web.MockHttpServletResponse;
4040
import org.springframework.mock.web.MockHttpSession;
4141
import org.springframework.test.web.servlet.MockMvc;
42-
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
4342
import org.springframework.util.Assert;
4443
import org.springframework.util.LinkedMultiValueMap;
4544
import org.springframework.util.MultiValueMap;
@@ -57,11 +56,11 @@
5756
import org.springframework.web.util.UriUtils;
5857

5958
/**
60-
* Default builder for {@link MockHttpServletRequest} required as input to
61-
* perform request in {@link MockMvc}.
59+
* Default builder for {@link MockHttpServletRequest} required as input to perform
60+
* requests in {@link MockMvc}.
6261
*
63-
* <p>Application tests will typically access this builder through the static
64-
* factory methods in {@link MockMvcBuilders}.
62+
* <p>Application tests will typically access this builder through the static factory
63+
* methods in {@link org.springframework.test.web.servlet.setup.MockMvcBuilders}.
6564
*
6665
* @author Rossen Stoyanchev
6766
* @author Arjen Poutsma
@@ -70,7 +69,6 @@
7069
public class MockHttpServletRequestBuilder
7170
implements ConfigurableSmartRequestBuilder<MockHttpServletRequestBuilder>, Mergeable {
7271

73-
7472
private final HttpMethod method;
7573

7674
private final UriComponents uriComponents;
@@ -144,6 +142,7 @@ public class MockHttpServletRequestBuilder
144142
this.uriComponents = UriComponentsBuilder.fromUri(uri).build();
145143
}
146144

145+
147146
/**
148147
* Add a request parameter to the {@link MockHttpServletRequest}.
149148
* If called more than once, the new values are added.
@@ -429,6 +428,7 @@ public MockHttpServletRequestBuilder with(RequestPostProcessor postProcessor) {
429428
return this;
430429
}
431430

431+
432432
/**
433433
* {@inheritDoc}
434434
* @return always returns {@code true}.

spring-web/src/test/java/org/springframework/web/filter/RequestLoggingFilterTests.java

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,20 +18,21 @@
1818

1919
import java.io.IOException;
2020
import javax.servlet.FilterChain;
21+
import javax.servlet.ServletException;
2122
import javax.servlet.ServletRequest;
2223
import javax.servlet.ServletResponse;
23-
import javax.servlet.ServletException;
24-
import javax.servlet.http.HttpServletResponse;
2524
import javax.servlet.http.HttpServletRequest;
25+
import javax.servlet.http.HttpServletResponse;
2626

27-
import org.junit.Test;
2827
import org.junit.Before;
29-
import static org.junit.Assert.*;
28+
import org.junit.Test;
3029

3130
import org.springframework.mock.web.test.MockHttpServletRequest;
3231
import org.springframework.mock.web.test.MockHttpServletResponse;
3332
import org.springframework.util.FileCopyUtils;
3433

34+
import static org.junit.Assert.*;
35+
3536
/**
3637
* Test for {@link AbstractRequestLoggingFilter} and sub classes.
3738
*
@@ -41,29 +42,31 @@ public class RequestLoggingFilterTests {
4142

4243
private MyRequestLoggingFilter filter;
4344

45+
4446
@Before
4547
public void createFilter() throws Exception {
4648
filter = new MyRequestLoggingFilter();
4749
}
4850

51+
4952
@Test
5053
public void uri() throws Exception {
5154
final MockHttpServletRequest request = new MockHttpServletRequest("POST", "/hotels");
5255
MockHttpServletResponse response = new MockHttpServletResponse();
5356

5457
request.setQueryString("booking=42");
5558

56-
FilterChain filterChain = new NoopFilterChain();
59+
FilterChain filterChain = new NoOpFilterChain();
5760

5861
filter.doFilter(request, response, filterChain);
5962

6063
assertNotNull(filter.beforeRequestMessage);
61-
assertTrue(filter.beforeRequestMessage.indexOf("uri=/hotel") != -1);
62-
assertFalse(filter.beforeRequestMessage.indexOf("booking=42") != -1);
64+
assertTrue(filter.beforeRequestMessage.contains("uri=/hotel"));
65+
assertFalse(filter.beforeRequestMessage.contains("booking=42"));
6366

6467
assertNotNull(filter.afterRequestMessage);
65-
assertTrue(filter.afterRequestMessage.indexOf("uri=/hotel") != -1);
66-
assertFalse(filter.afterRequestMessage.indexOf("booking=42") != -1);
68+
assertTrue(filter.afterRequestMessage.contains("uri=/hotel"));
69+
assertFalse(filter.afterRequestMessage.contains("booking=42"));
6770
}
6871

6972
@Test
@@ -75,15 +78,15 @@ public void queryString() throws Exception {
7578

7679
request.setQueryString("booking=42");
7780

78-
FilterChain filterChain = new NoopFilterChain();
81+
FilterChain filterChain = new NoOpFilterChain();
7982

8083
filter.doFilter(request, response, filterChain);
8184

8285
assertNotNull(filter.beforeRequestMessage);
83-
assertTrue(filter.beforeRequestMessage.indexOf("uri=/hotels?booking=42") != -1);
86+
assertTrue(filter.beforeRequestMessage.contains("uri=/hotels?booking=42"));
8487

8588
assertNotNull(filter.afterRequestMessage);
86-
assertTrue(filter.afterRequestMessage.indexOf("uri=/hotels?booking=42") != -1);
89+
assertTrue(filter.afterRequestMessage.contains("uri=/hotels?booking=42"));
8790
}
8891

8992
@Test
@@ -109,7 +112,7 @@ public void doFilter(ServletRequest filterRequest, ServletResponse filterRespons
109112
filter.doFilter(request, response, filterChain);
110113

111114
assertNotNull(filter.afterRequestMessage);
112-
assertTrue(filter.afterRequestMessage.indexOf("Hello World") != -1);
115+
assertTrue(filter.afterRequestMessage.contains("Hello World"));
113116
}
114117

115118
@Test
@@ -135,7 +138,7 @@ public void doFilter(ServletRequest filterRequest, ServletResponse filterRespons
135138
filter.doFilter(request, response, filterChain);
136139

137140
assertNotNull(filter.afterRequestMessage);
138-
assertTrue(filter.afterRequestMessage.indexOf(requestBody) != -1);
141+
assertTrue(filter.afterRequestMessage.contains(requestBody));
139142
}
140143

141144
@Test
@@ -162,10 +165,11 @@ public void doFilter(ServletRequest filterRequest, ServletResponse filterRespons
162165
filter.doFilter(request, response, filterChain);
163166

164167
assertNotNull(filter.afterRequestMessage);
165-
assertTrue(filter.afterRequestMessage.indexOf("Hel") != -1);
166-
assertFalse(filter.afterRequestMessage.indexOf("Hello World") != -1);
168+
assertTrue(filter.afterRequestMessage.contains("Hel"));
169+
assertFalse(filter.afterRequestMessage.contains("Hello World"));
167170
}
168171

172+
169173
private static class MyRequestLoggingFilter extends AbstractRequestLoggingFilter {
170174

171175
private String beforeRequestMessage;
@@ -183,7 +187,8 @@ protected void afterRequest(HttpServletRequest request, String message) {
183187
}
184188
}
185189

186-
private static class NoopFilterChain implements FilterChain {
190+
191+
private static class NoOpFilterChain implements FilterChain {
187192

188193
@Override
189194
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {

0 commit comments

Comments
 (0)