Skip to content

Commit 8a96d1a

Browse files
committed
Polishing
1 parent ef1748f commit 8a96d1a

File tree

5 files changed

+28
-25
lines changed

5 files changed

+28
-25
lines changed

spring-context/src/main/java/org/springframework/cache/CacheManager.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
import java.util.Collection;
2020

2121
/**
22-
* A manager for a set of {@link Cache}s.
22+
* Spring's central cache manager SPI.
23+
* Allows for retrieving named {@link Cache} regions.
2324
*
2425
* @author Costin Leau
2526
* @since 3.1
@@ -28,14 +29,14 @@ public interface CacheManager {
2829

2930
/**
3031
* Return the cache associated with the given name.
31-
* @param name cache identifier (must not be {@code null})
32-
* @return the associated cache, or {@code null} if none is found
32+
* @param name the cache identifier (must not be {@code null})
33+
* @return the associated cache, or {@code null} if none found
3334
*/
3435
Cache getCache(String name);
3536

3637
/**
37-
* Return a collection of the caches known by this cache manager.
38-
* @return names of caches known by the cache manager
38+
* Return a collection of the cache names known by this manager.
39+
* @return the names of all caches known by the cache manager
3940
*/
4041
Collection<String> getCacheNames();
4142

spring-web/src/main/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolver.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -33,25 +33,28 @@
3333
import org.springframework.web.method.HandlerMethodSelector;
3434

3535
/**
36-
* Discovers annotated exception handling methods in a given class type, including all
37-
* super types, and helps to resolve an Exception to a method that can handle it. The
38-
* exception types supported by a given method can also be discovered from the method
39-
* signature.
36+
* Discovers {@linkplain ExceptionHandler @ExceptionHandler} methods in a given class,
37+
* including all of its superclasses, and helps to resolve a given {@link Exception}
38+
* to the exception types supported by a given {@link Method}.
4039
*
4140
* @author Rossen Stoyanchev
4241
* @since 3.1
4342
*/
4443
public class ExceptionHandlerMethodResolver {
4544

46-
/** A filter for selecting annotated exception handling methods. */
47-
public final static MethodFilter EXCEPTION_HANDLER_METHODS = new MethodFilter() {
48-
45+
/**
46+
* A filter for selecting {@code @ExceptionHandler} methods.
47+
*/
48+
public static final MethodFilter EXCEPTION_HANDLER_METHODS = new MethodFilter() {
4949
@Override
5050
public boolean matches(Method method) {
5151
return (AnnotationUtils.findAnnotation(method, ExceptionHandler.class) != null);
5252
}
5353
};
5454

55+
/**
56+
* Arbitrary {@link Method} reference, indicating no method found in the cache.
57+
*/
5558
private static final Method NO_METHOD_FOUND = ClassUtils.getMethodIfAvailable(System.class, "currentTimeMillis");
5659

5760

@@ -116,26 +119,26 @@ public boolean hasExceptionMappings() {
116119
}
117120

118121
/**
119-
* Find a method to handle the given exception.
122+
* Find a {@link Method} to handle the given exception.
120123
* Use {@link ExceptionDepthComparator} if more than one match is found.
121124
* @param exception the exception
122-
* @return a method to handle the exception or {@code null}
125+
* @return a Method to handle the exception, or {@code null} if none found
123126
*/
124127
public Method resolveMethod(Exception exception) {
125128
return resolveMethodByExceptionType(exception.getClass());
126129
}
127130

128131
/**
129-
* Find a method to handle the given exception type. This can be useful if
130-
* an Exception instance is not available (example for tools).
132+
* Find a {@link Method} to handle the given exception type. This can be
133+
* useful if an {@link Exception} instance is not available (e.g. for tools).
131134
* @param exceptionType the exception type
132-
* @return a method to handle the exception or {@code null}
135+
* @return a Method to handle the exception, or {@code null} if none found
133136
*/
134137
public Method resolveMethodByExceptionType(Class<? extends Exception> exceptionType) {
135138
Method method = this.exceptionLookupCache.get(exceptionType);
136139
if (method == null) {
137140
method = getMappedMethod(exceptionType);
138-
this.exceptionLookupCache.put(exceptionType, method != null ? method : NO_METHOD_FOUND);
141+
this.exceptionLookupCache.put(exceptionType, (method != null ? method : NO_METHOD_FOUND));
139142
}
140143
return method != NO_METHOD_FOUND ? method : null;
141144
}
@@ -152,7 +155,7 @@ private Method getMappedMethod(Class<? extends Exception> exceptionType) {
152155
}
153156
if (!matches.isEmpty()) {
154157
Collections.sort(matches, new ExceptionDepthComparator(exceptionType));
155-
return mappedMethods.get(matches.get(0));
158+
return this.mappedMethods.get(matches.get(0));
156159
}
157160
else {
158161
return null;

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ProducesRequestCondition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ public int compareTo(ProducesRequestCondition other, HttpServletRequest request)
226226
}
227227
return 0;
228228
}
229-
catch (HttpMediaTypeNotAcceptableException e) {
229+
catch (HttpMediaTypeNotAcceptableException ex) {
230230
// should never happen
231-
throw new IllegalStateException("Cannot compare without having any requested media types");
231+
throw new IllegalStateException("Cannot compare without having any requested media types", ex);
232232
}
233233
}
234234

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/RequestMethodsRequestCondition.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ public RequestMethodsRequestCondition combine(RequestMethodsRequestCondition oth
8989
/**
9090
* Check if any of the HTTP request methods match the given request and
9191
* return an instance that contains the matching HTTP request method only.
92-
*
9392
* @param request the current request
9493
* @return the same instance if the condition is empty, a new condition with
9594
* the matched request method, or {@code null} if no request methods match
@@ -114,7 +113,7 @@ private RequestMethod getRequestMethod(HttpServletRequest request) {
114113
try {
115114
return RequestMethod.valueOf(request.getMethod());
116115
}
117-
catch (IllegalArgumentException e) {
116+
catch (IllegalArgumentException ex) {
118117
return null;
119118
}
120119
}

spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/FormTag.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ protected int writeTagContent(TagWriter tagWriter) throws JspException {
383383
}
384384

385385
private String getHttpMethod() {
386-
return isMethodBrowserSupported(getMethod()) ? getMethod() : DEFAULT_METHOD;
386+
return (isMethodBrowserSupported(getMethod()) ? getMethod() : DEFAULT_METHOD);
387387
}
388388

389389
private void assertHttpMethod(String method) {

0 commit comments

Comments
 (0)