Consistent hasAnnotation check for findMergedAnnotation lookup
Issue: SPR-16933
This commit is contained in:
@@ -25,7 +25,7 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.core.ExceptionDepthComparator;
|
||||
import org.springframework.core.MethodIntrospector;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
@@ -47,7 +47,7 @@ public class ExceptionHandlerMethodResolver {
|
||||
* A filter for selecting {@code @ExceptionHandler} methods.
|
||||
*/
|
||||
public static final MethodFilter EXCEPTION_HANDLER_METHODS = method ->
|
||||
(AnnotationUtils.findAnnotation(method, ExceptionHandler.class) != null);
|
||||
AnnotatedElementUtils.hasAnnotation(method, ExceptionHandler.class);
|
||||
|
||||
|
||||
private final Map<Class<? extends Throwable>, Method> mappedMethods = new HashMap<>(16);
|
||||
@@ -89,8 +89,8 @@ public class ExceptionHandlerMethodResolver {
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void detectAnnotationExceptionMappings(Method method, List<Class<? extends Throwable>> result) {
|
||||
ExceptionHandler ann = AnnotationUtils.findAnnotation(method, ExceptionHandler.class);
|
||||
private void detectAnnotationExceptionMappings(Method method, List<Class<? extends Throwable>> result) {
|
||||
ExceptionHandler ann = AnnotatedElementUtils.findMergedAnnotation(method, ExceptionHandler.class);
|
||||
Assert.state(ann != null, "No ExceptionHandler annotation");
|
||||
result.addAll(Arrays.asList(ann.value()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user