Browse Source

Polishing

pull/28964/head
Sam Brannen 2 years ago
parent
commit
a052f9a34e
  1. 3
      spring-core/src/main/java/org/springframework/aot/hint/support/RuntimeHintsUtils.java
  2. 12
      spring-core/src/test/java/org/springframework/aot/hint/support/RuntimeHintsUtilsTests.java
  3. 4
      spring-web/src/main/java/org/springframework/web/bind/annotation/WebAnnotationsRuntimeHintsRegistrar.java

3
spring-core/src/main/java/org/springframework/aot/hint/support/RuntimeHintsUtils.java

@ -100,8 +100,7 @@ public abstract class RuntimeHintsUtils { @@ -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);
}

12
spring-core/src/test/java/org/springframework/aot/hint/support/RuntimeHintsUtilsTests.java

@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test; @@ -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 { @@ -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 { @@ -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 { @@ -117,8 +116,7 @@ class RuntimeHintsUtilsTests {
private Consumer<JdkProxyHint> 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 { @@ -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;

4
spring-web/src/main/java/org/springframework/web/bind/annotation/WebAnnotationsRuntimeHintsRegistrar.java

@ -25,8 +25,8 @@ import org.springframework.lang.Nullable; @@ -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

Loading…
Cancel
Save