diff --git a/core/src/main/java/org/springframework/security/core/annotation/ExpressionTemplateSecurityAnnotationScanner.java b/core/src/main/java/org/springframework/security/core/annotation/ExpressionTemplateSecurityAnnotationScanner.java index 6efab386726..0d8c86a3bb6 100644 --- a/core/src/main/java/org/springframework/security/core/annotation/ExpressionTemplateSecurityAnnotationScanner.java +++ b/core/src/main/java/org/springframework/security/core/annotation/ExpressionTemplateSecurityAnnotationScanner.java @@ -99,26 +99,15 @@ final class ExpressionTemplateSecurityAnnotationScanner @Override @Nullable MergedAnnotation merge(AnnotatedElement element, @Nullable Class targetClass) { if (element instanceof Parameter parameter) { - MergedAnnotation annotation = this.unique.merge(parameter, targetClass); - if (annotation == null) { - return null; - } - return resolvePlaceholders(annotation); + return resolvePlaceholders(this.unique.merge(parameter, targetClass)); } if (element instanceof Method method) { - MergedAnnotation annotation = this.unique.merge(method, targetClass); - if (annotation == null) { - return null; - } - return resolvePlaceholders(annotation); + return resolvePlaceholders(this.unique.merge(method, targetClass)); } throw new IllegalArgumentException("Unsupported element of type " + element.getClass()); } private MergedAnnotation resolvePlaceholders(MergedAnnotation mergedAnnotation) { - if (this.templateDefaults == null) { - return mergedAnnotation; - } if (mergedAnnotation.getMetaSource() == null) { return mergedAnnotation; } diff --git a/core/src/main/java/org/springframework/security/core/annotation/UniqueSecurityAnnotationScanner.java b/core/src/main/java/org/springframework/security/core/annotation/UniqueSecurityAnnotationScanner.java index 75c12eac47e..a4776ed5311 100644 --- a/core/src/main/java/org/springframework/security/core/annotation/UniqueSecurityAnnotationScanner.java +++ b/core/src/main/java/org/springframework/security/core/annotation/UniqueSecurityAnnotationScanner.java @@ -163,7 +163,7 @@ private List> findParameterAnnotations(Parameter current) { private List> findClosestParameterAnnotations(Method method, Class clazz, Parameter current, Set> visited) { - if (clazz == null || clazz == Object.class || !visited.add(clazz)) { + if (clazz == Object.class || !visited.add(clazz)) { return Collections.emptyList(); } List> directAnnotations = findDirectParameterAnnotations(method, clazz, current); @@ -224,7 +224,7 @@ private List> findMethodAnnotations(Method method, @Nullable private List> findClosestMethodAnnotations(Method method, Class targetClass, Set> classesToSkip) { - if (targetClass == null || classesToSkip.contains(targetClass) || targetClass == Object.class) { + if (classesToSkip.contains(targetClass) || targetClass == Object.class) { return Collections.emptyList(); } classesToSkip.add(targetClass); @@ -244,7 +244,7 @@ private List> findClosestMethodAnnotations(Method method, Cl } private List> findClosestClassAnnotations(Class targetClass, Set> classesToSkip) { - if (targetClass == null || classesToSkip.contains(targetClass) || targetClass == Object.class) { + if (classesToSkip.contains(targetClass) || targetClass == Object.class) { return Collections.emptyList(); } classesToSkip.add(targetClass);