Filter repeatable annotations in AnnotationTypeMappings
Prior to this commit, AnnotationTypeMappings did not filter repeatable annotations with the supplied annotation filter. Closes gh-25483
This commit is contained in:
committed by
Sam Brannen
parent
b841e8560c
commit
83a95832e6
@@ -89,7 +89,7 @@ final class AnnotationTypeMappings {
|
||||
Annotation[] repeatedAnnotations = this.repeatableContainers.findRepeatedAnnotations(metaAnnotation);
|
||||
if (repeatedAnnotations != null) {
|
||||
for (Annotation repeatedAnnotation : repeatedAnnotations) {
|
||||
if (!isMappable(source, metaAnnotation)) {
|
||||
if (!isMappable(source, repeatedAnnotation)) {
|
||||
continue;
|
||||
}
|
||||
addIfPossible(queue, source, repeatedAnnotation);
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.annotation.AnnotationTypeMapping.MirrorSets;
|
||||
import org.springframework.core.annotation.AnnotationTypeMapping.MirrorSets.MirrorSet;
|
||||
import org.springframework.lang.UsesSunMisc;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
@@ -476,6 +477,16 @@ class AnnotationTypeMappingsTests {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Test
|
||||
void forAnnotationTypeWhenRepeatableMetaAnnotationFilterd() {
|
||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(WithRepeatedMetaAnnotations.class,
|
||||
annotationType ->
|
||||
ObjectUtils.nullSafeEquals(annotationType, Repeating.class.getName()));
|
||||
assertThat(getAll(mappings)).flatExtracting(
|
||||
AnnotationTypeMapping::getAnnotationType).containsExactly(
|
||||
WithRepeatedMetaAnnotations.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Method getAliasMapping(AnnotationTypeMapping mapping, int attributeIndex) {
|
||||
int mapped = mapping.getAliasMapping(attributeIndex);
|
||||
|
||||
Reference in New Issue
Block a user