Honor default values for implicit aliases in composed annotations
Spring Framework 5.2 introduced a regression for implicit aliases declared via @AliasFor. Specifically, Spring's merged annotation algorithms stopped honoring default values for implicit alias pairs if the composed annotation was used without specifying the aliased attributes. This commit fixes this regression. Closes gh-24110
This commit is contained in:
parent
1bff7ce141
commit
6f15f32be3
|
@ -646,6 +646,9 @@ final class AnnotationTypeMapping {
|
|||
boolean isDefaultValue = (value == null ||
|
||||
isEquivalentToDefaultValue(attribute, value, valueExtractor));
|
||||
if (isDefaultValue || ObjectUtils.nullSafeEquals(lastValue, value)) {
|
||||
if (result == -1) {
|
||||
result = this.indexes[i];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (lastValue != null && !ObjectUtils.nullSafeEquals(lastValue, value)) {
|
||||
|
|
|
@ -368,13 +368,13 @@ class AnnotationTypeMappingsTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
void resolveMirrorsWhenOnlyHasDefaultValuesResolvesNone() {
|
||||
void resolveMirrorsWhenOnlyHasDefaultValuesUsesFirst() {
|
||||
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
|
||||
AliasPair.class).get(0);
|
||||
Method[] resolved = resolveMirrorSets(mapping, WithDefaultValueAliasPair.class,
|
||||
AliasPair.class);
|
||||
assertThat(resolved[0]).isNull();
|
||||
assertThat(resolved[1]).isNull();
|
||||
assertThat(resolved[0].getName()).isEqualTo("a");
|
||||
assertThat(resolved[1].getName()).isEqualTo("a");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue