diff --git a/spring-core/src/main/java/org/springframework/aot/hint/support/RuntimeHintsUtils.java b/spring-core/src/main/java/org/springframework/aot/hint/support/RuntimeHintsUtils.java index 089860a737..0679bca86e 100644 --- a/spring-core/src/main/java/org/springframework/aot/hint/support/RuntimeHintsUtils.java +++ b/spring-core/src/main/java/org/springframework/aot/hint/support/RuntimeHintsUtils.java @@ -100,8 +100,7 @@ public abstract class RuntimeHintsUtils { Class annotationAttribute = aliasFor.annotation(); Class targetAnnotation = (annotationAttribute != Annotation.class ? annotationAttribute : annotationType); - if (!types.contains(targetAnnotation)) { - types.add(targetAnnotation); + if (types.add(targetAnnotation)) { if (!targetAnnotation.equals(annotationType)) { collectAliasedAnnotations(seen, types, targetAnnotation); } diff --git a/spring-core/src/test/java/org/springframework/aot/hint/support/RuntimeHintsUtilsTests.java b/spring-core/src/test/java/org/springframework/aot/hint/support/RuntimeHintsUtilsTests.java index 6d4a3c30ff..b4345a91ea 100644 --- a/spring-core/src/test/java/org/springframework/aot/hint/support/RuntimeHintsUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/aot/hint/support/RuntimeHintsUtilsTests.java @@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test; import org.springframework.aot.hint.JdkProxyHint; import org.springframework.aot.hint.MemberCategory; -import org.springframework.aot.hint.ReflectionHints; import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.TypeHint; import org.springframework.aot.hint.TypeReference; @@ -74,7 +73,8 @@ class RuntimeHintsUtilsTests { RuntimeHintsUtils.registerAnnotation(this.hints, RetryInvoker.class); assertThat(this.hints.reflection().typeHints()) .anySatisfy(annotationHint(RetryInvoker.class)) - .anySatisfy(annotationHint(SampleInvoker.class)); + .anySatisfy(annotationHint(SampleInvoker.class)) + .hasSize(2); assertThat(this.hints.proxies().jdkProxies()) .anySatisfy(annotationProxy(RetryInvoker.class)) .anySatisfy(annotationProxy(SampleInvoker.class)) @@ -92,8 +92,7 @@ class RuntimeHintsUtilsTests { @Test void registerAnnotationTypeWhereUsedAsAMetaAnnotationRegistersHierarchy() { RuntimeHintsUtils.registerAnnotation(this.hints, RetryWithEnabledFlagInvoker.class); - ReflectionHints reflection = this.hints.reflection(); - assertThat(reflection.typeHints()) + assertThat(this.hints.reflection().typeHints()) .anySatisfy(annotationHint(RetryWithEnabledFlagInvoker.class)) .anySatisfy(annotationHint(RetryInvoker.class)) .anySatisfy(annotationHint(SampleInvoker.class)) @@ -117,8 +116,7 @@ class RuntimeHintsUtilsTests { private Consumer annotationProxy(Class type) { return jdkProxyHint -> assertThat(jdkProxyHint.getProxiedInterfaces()) - .containsExactly(TypeReference.of(type), - TypeReference.of(SynthesizedAnnotation.class)); + .containsExactly(TypeReference.of(type), TypeReference.of(SynthesizedAnnotation.class)); } @@ -154,7 +152,7 @@ class RuntimeHintsUtilsTests { @RetryInvoker @interface RetryWithEnabledFlagInvoker { - @AliasFor(attribute = "value", annotation = RetryInvoker.class) + @AliasFor(annotation = RetryInvoker.class) int value() default 5; boolean enabled() default true; diff --git a/spring-web/src/main/java/org/springframework/web/bind/annotation/WebAnnotationsRuntimeHintsRegistrar.java b/spring-web/src/main/java/org/springframework/web/bind/annotation/WebAnnotationsRuntimeHintsRegistrar.java index 1adc3ba2f0..3e6e3e2b5f 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/annotation/WebAnnotationsRuntimeHintsRegistrar.java +++ b/spring-web/src/main/java/org/springframework/web/bind/annotation/WebAnnotationsRuntimeHintsRegistrar.java @@ -25,8 +25,8 @@ import org.springframework.lang.Nullable; import org.springframework.stereotype.Controller; /** - * {@link RuntimeHintsRegistrar} implementation that make web binding - * annotations at runtime. + * {@link RuntimeHintsRegistrar} implementation that makes web binding + * annotations available at runtime. * * @author Stephane Nicoll * @since 6.0