Skip to content

Commit

Permalink
Honor default values for implicit aliases in composed annotations
Browse files Browse the repository at this point in the history
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
  • Loading branch information
iiiron authored and sbrannen committed Dec 3, 2019
1 parent 1bff7ce commit 6f15f32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,9 @@ <A> int resolve(@Nullable Object source, @Nullable A annotation,
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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,13 @@ void resolveMirrorsWhenHasSameValuesUsesFirst() {
}

@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
Expand Down

0 comments on commit 6f15f32

Please sign in to comment.