Skip to content

Commit e3438aa

Browse files
committed
Support AliasFor
Closes gh-15436
1 parent 03bcc67 commit e3438aa

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

core/src/main/java/org/springframework/security/authorization/method/AuthorizationAnnotationUtils.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,7 @@ private static <A extends Annotation> A findDistinctAnnotation(AnnotatedElement
136136
Class<A> annotationType, Function<MergedAnnotation<A>, A> map) {
137137
MergedAnnotations mergedAnnotations = MergedAnnotations.from(annotatedElement, SearchStrategy.TYPE_HIERARCHY,
138138
RepeatableContainers.none());
139-
List<A> annotations = mergedAnnotations.stream(annotationType)
140-
.map(MergedAnnotation::withNonMergedAttributes)
141-
.map(map)
142-
.distinct()
143-
.toList();
139+
List<A> annotations = mergedAnnotations.stream(annotationType).map(map).distinct().toList();
144140

145141
return switch (annotations.size()) {
146142
case 0 -> null;

core/src/test/java/org/springframework/security/authorization/method/AuthorizationAnnotationUtilsTests.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,7 @@ void competingAnnotationsOnMethodShouldTriggerAnnotationConfigurationException()
9090
void composedMergedAnnotationsAreNotSupported() {
9191
Class<?> clazz = ComposedPreAuthAnnotationOnClass.class;
9292
PreAuthorize preAuthorize = AuthorizationAnnotationUtils.findUniqueAnnotation(clazz, PreAuthorize.class);
93-
94-
// If you comment out .map(MergedAnnotation::withNonMergedAttributes) in
95-
// AuthorizationAnnotationUtils.findDistinctAnnotation(), the value of
96-
// the merged annotation would be "hasRole('composedRole')".
97-
assertThat(preAuthorize.value()).isEqualTo("hasRole('metaRole')");
93+
assertThat(preAuthorize.value()).isEqualTo("hasRole('composedRole')");
9894
}
9995

10096
private interface BaseRepository<T> {

0 commit comments

Comments
 (0)