Support AliasFor

Closes gh-15436
This commit is contained in:
Josh Cummings 2024-07-17 12:22:15 -06:00
parent 03bcc6776a
commit e3438aa36a
No known key found for this signature in database
GPG Key ID: A306A51F43B8E5A5
2 changed files with 2 additions and 10 deletions

View File

@ -136,11 +136,7 @@ final class AuthorizationAnnotationUtils {
Class<A> annotationType, Function<MergedAnnotation<A>, A> map) {
MergedAnnotations mergedAnnotations = MergedAnnotations.from(annotatedElement, SearchStrategy.TYPE_HIERARCHY,
RepeatableContainers.none());
List<A> annotations = mergedAnnotations.stream(annotationType)
.map(MergedAnnotation::withNonMergedAttributes)
.map(map)
.distinct()
.toList();
List<A> annotations = mergedAnnotations.stream(annotationType).map(map).distinct().toList();
return switch (annotations.size()) {
case 0 -> null;

View File

@ -90,11 +90,7 @@ class AuthorizationAnnotationUtilsTests {
void composedMergedAnnotationsAreNotSupported() {
Class<?> clazz = ComposedPreAuthAnnotationOnClass.class;
PreAuthorize preAuthorize = AuthorizationAnnotationUtils.findUniqueAnnotation(clazz, PreAuthorize.class);
// If you comment out .map(MergedAnnotation::withNonMergedAttributes) in
// AuthorizationAnnotationUtils.findDistinctAnnotation(), the value of
// the merged annotation would be "hasRole('composedRole')".
assertThat(preAuthorize.value()).isEqualTo("hasRole('metaRole')");
assertThat(preAuthorize.value()).isEqualTo("hasRole('composedRole')");
}
private interface BaseRepository<T> {