Skip to content

Commit

Permalink
Support AliasFor
Browse files Browse the repository at this point in the history
Closes gh-15436
  • Loading branch information
jzheaux committed Jul 18, 2024
1 parent 03bcc67 commit e3438aa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,7 @@ private static <A extends Annotation> A findDistinctAnnotation(AnnotatedElement
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ void competingAnnotationsOnMethodShouldTriggerAnnotationConfigurationException()
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> {
Expand Down

0 comments on commit e3438aa

Please sign in to comment.