Skip to content

Commit 888ccfe

Browse files
committed
Adapt to changes in Spring Framework
1 parent 12d9864 commit 888ccfe

File tree

4 files changed

+20
-37
lines changed

4 files changed

+20
-37
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/ActuatorAnnotationsRuntimeHints.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@
2121
import org.springframework.aot.hint.RuntimeHints;
2222
import org.springframework.aot.hint.RuntimeHintsRegistrar;
2323
import org.springframework.aot.hint.support.RuntimeHintsUtils;
24-
import org.springframework.boot.actuate.endpoint.annotation.DeleteOperation;
2524
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
2625
import org.springframework.boot.actuate.endpoint.annotation.EndpointExtension;
27-
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
28-
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
2926

3027
/**
3128
* {@link RuntimeHintsRegistrar} for actuator support.
@@ -36,10 +33,8 @@ class ActuatorAnnotationsRuntimeHints implements RuntimeHintsRegistrar {
3633

3734
@Override
3835
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
39-
Stream.of(ReadOperation.class, WriteOperation.class, DeleteOperation.class)
40-
.forEach((annotationType) -> RuntimeHintsUtils.registerAnnotation(hints, annotationType));
4136
Stream.of(Endpoint.class, EndpointExtension.class)
42-
.forEach((annotationType) -> RuntimeHintsUtils.registerComposableAnnotation(hints, annotationType));
37+
.forEach((annotationType) -> RuntimeHintsUtils.registerSynthesizedAnnotation(hints, annotationType));
4338
}
4439

4540
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/ActuatorAnnotationsRuntimeHintsTests.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,10 @@
2121
import org.junit.jupiter.api.BeforeEach;
2222
import org.junit.jupiter.api.Test;
2323

24-
import org.springframework.aot.hint.MemberCategory;
2524
import org.springframework.aot.hint.RuntimeHints;
2625
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
27-
import org.springframework.boot.actuate.endpoint.annotation.DeleteOperation;
2826
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
2927
import org.springframework.boot.actuate.endpoint.annotation.EndpointExtension;
30-
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
31-
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
3228
import org.springframework.core.annotation.SynthesizedAnnotation;
3329

3430
import static org.assertj.core.api.Assertions.assertThat;
@@ -50,16 +46,6 @@ void setUp() {
5046
this.registrar.registerHints(this.runtimeHints, getClass().getClassLoader());
5147
}
5248

53-
@Test
54-
void shouldRegisterReflectionHints() {
55-
Set<Class<?>> annotations = Set.of(Endpoint.class, ReadOperation.class, WriteOperation.class,
56-
DeleteOperation.class, EndpointExtension.class);
57-
for (Class<?> annotation : annotations) {
58-
assertThat(RuntimeHintsPredicates.reflection().onType(annotation)
59-
.withAnyMemberCategory(MemberCategory.INVOKE_DECLARED_METHODS)).accepts(this.runtimeHints);
60-
}
61-
}
62-
6349
@Test
6450
void shouldRegisterProxyHints() {
6551
Set<Class<?>> synthesizedAnnotations = Set.of(Endpoint.class, EndpointExtension.class);

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanFactoryInitializationAotProcessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ private ConfigurationPropertiesReflectionHintsContribution(Iterable<Class<?>> ty
6767
@Override
6868
public void applyTo(GenerationContext generationContext,
6969
BeanFactoryInitializationCode beanFactoryInitializationCode) {
70-
RuntimeHintsUtils.registerAnnotation(generationContext.getRuntimeHints(), ConfigurationProperties.class);
70+
RuntimeHintsUtils.registerSynthesizedAnnotation(generationContext.getRuntimeHints(),
71+
ConfigurationProperties.class);
7172
for (Class<?> type : this.types) {
7273
ConfigurationPropertiesReflectionHintsProcessor.processConfigurationProperties(type,
7374
generationContext.getRuntimeHints().reflection());

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanFactoryInitializationAotProcessorTests.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.springframework.context.ApplicationContext;
4747
import org.springframework.context.ApplicationContextAware;
4848
import org.springframework.context.EnvironmentAware;
49+
import org.springframework.core.annotation.SynthesizedAnnotation;
4950
import org.springframework.core.env.Environment;
5051

5152
import static org.assertj.core.api.Assertions.assertThat;
@@ -86,8 +87,10 @@ void processManuallyRegisteredSingleton() {
8687
@Test
8788
void registerConfigurationPropertiesAnnotation() {
8889
RuntimeHints runtimeHints = process(SampleProperties.class);
89-
assertThat(runtimeHints.reflection().getTypeHint(ConfigurationProperties.class)).satisfies(
90-
(hint) -> assertThat(hint.getMemberCategories()).contains(MemberCategory.INVOKE_DECLARED_METHODS));
90+
assertThat(runtimeHints.proxies().jdkProxies()).singleElement()
91+
.satisfies((hint) -> assertThat(hint.getProxiedInterfaces()).containsExactly(
92+
TypeReference.of(ConfigurationProperties.class),
93+
TypeReference.of(SynthesizedAnnotation.class)));
9194
}
9295

9396
@Test
@@ -111,7 +114,7 @@ void processJavaBeanConfigurationPropertiesWithMapOfPojo() {
111114
List<TypeHint> typeHints = runtimeHints.reflection().typeHints().toList();
112115
assertThat(typeHints).anySatisfy(javaBeanBinding(SamplePropertiesWithMap.class));
113116
assertThat(typeHints).anySatisfy(javaBeanBinding(Address.class));
114-
assertThat(typeHints).hasSize(3);
117+
assertThat(typeHints).hasSize(2);
115118
}
116119

117120
@Test
@@ -120,7 +123,7 @@ void processJavaBeanConfigurationPropertiesWithListOfPojo() {
120123
List<TypeHint> typeHints = runtimeHints.reflection().typeHints().toList();
121124
assertThat(typeHints).anySatisfy(javaBeanBinding(SamplePropertiesWithList.class));
122125
assertThat(typeHints).anySatisfy(javaBeanBinding(Address.class));
123-
assertThat(typeHints).hasSize(3);
126+
assertThat(typeHints).hasSize(2);
124127
}
125128

126129
@Test
@@ -129,15 +132,15 @@ void processJavaBeanConfigurationPropertiesWitArrayOfPojo() {
129132
List<TypeHint> typeHints = runtimeHints.reflection().typeHints().toList();
130133
assertThat(typeHints).anySatisfy(javaBeanBinding(SamplePropertiesWithArray.class));
131134
assertThat(typeHints).anySatisfy(javaBeanBinding(Address.class));
132-
assertThat(typeHints).hasSize(3);
135+
assertThat(typeHints).hasSize(2);
133136
}
134137

135138
@Test
136139
void processJavaBeanConfigurationPropertiesWithListOfJavaType() {
137140
RuntimeHints runtimeHints = process(SamplePropertiesWithSimpleList.class);
138141
List<TypeHint> typeHints = runtimeHints.reflection().typeHints().toList();
139142
assertThat(typeHints).anySatisfy(javaBeanBinding(SamplePropertiesWithSimpleList.class));
140-
assertThat(typeHints).hasSize(2);
143+
assertThat(typeHints).hasSize(1);
141144
}
142145

143146
@Test
@@ -146,7 +149,7 @@ void processValueObjectConfigurationProperties() {
146149
List<TypeHint> typeHints = runtimeHints.reflection().typeHints().toList();
147150
assertThat(typeHints).anySatisfy(valueObjectBinding(SampleImmutableProperties.class,
148151
SampleImmutableProperties.class.getDeclaredConstructors()[0]));
149-
assertThat(typeHints).hasSize(2);
152+
assertThat(typeHints).hasSize(1);
150153
}
151154

152155
@Test
@@ -155,7 +158,7 @@ void processValueObjectConfigurationPropertiesWithSpecificConstructor() throws N
155158
List<TypeHint> typeHints = runtimeHints.reflection().typeHints().toList();
156159
assertThat(typeHints).anySatisfy(valueObjectBinding(SampleImmutablePropertiesWithSeveralConstructors.class,
157160
SampleImmutablePropertiesWithSeveralConstructors.class.getDeclaredConstructor(String.class)));
158-
assertThat(typeHints).hasSize(2);
161+
assertThat(typeHints).hasSize(1);
159162
}
160163

161164
@Test
@@ -166,7 +169,7 @@ void processValueObjectConfigurationPropertiesWithSeveralLayersOfPojo() {
166169
SampleImmutablePropertiesWithList.class.getDeclaredConstructors()[0]));
167170
assertThat(typeHints).anySatisfy(valueObjectBinding(Person.class, Person.class.getDeclaredConstructors()[0]));
168171
assertThat(typeHints).anySatisfy(valueObjectBinding(Address.class, Address.class.getDeclaredConstructors()[0]));
169-
assertThat(typeHints).hasSize(4);
172+
assertThat(typeHints).hasSize(3);
170173
}
171174

172175
@Test
@@ -182,15 +185,15 @@ void processConfigurationPropertiesWithNestedExternalType() {
182185
assertThat(runtimeHints.reflection().typeHints())
183186
.anySatisfy(javaBeanBinding(SamplePropertiesWithExternalNested.class))
184187
.anySatisfy(javaBeanBinding(SampleType.class)).anySatisfy(javaBeanBinding(SampleType.Nested.class))
185-
.hasSize(4);
188+
.hasSize(3);
186189
}
187190

188191
@Test
189192
void processConfigurationPropertiesWithRecursiveType() {
190193
RuntimeHints runtimeHints = process(SamplePropertiesWithRecursive.class);
191194
assertThat(runtimeHints.reflection().typeHints())
192195
.anySatisfy(javaBeanBinding(SamplePropertiesWithRecursive.class))
193-
.anySatisfy(javaBeanBinding(Recursive.class)).hasSize(3);
196+
.anySatisfy(javaBeanBinding(Recursive.class)).hasSize(2);
194197
}
195198

196199
@Test
@@ -201,16 +204,14 @@ void processValueObjectConfigurationPropertiesWithRecursiveType() {
201204
SampleImmutablePropertiesWithRecursive.class.getDeclaredConstructors()[0]))
202205
.anySatisfy(valueObjectBinding(ImmutableRecursive.class,
203206
ImmutableRecursive.class.getDeclaredConstructors()[0]))
204-
.hasSize(3);
207+
.hasSize(2);
205208
}
206209

207210
@Test
208211
void processConfigurationPropertiesWithWellKnownTypes() {
209212
RuntimeHints runtimeHints = process(SamplePropertiesWithWellKnownTypes.class);
210213
assertThat(runtimeHints.reflection().typeHints())
211-
.anySatisfy(javaBeanBinding(SamplePropertiesWithWellKnownTypes.class))
212-
// TODO
213-
.hasSize(2);
214+
.anySatisfy(javaBeanBinding(SamplePropertiesWithWellKnownTypes.class)).hasSize(1);
214215
}
215216

216217
@Test
@@ -219,7 +220,7 @@ void processConfigurationPropertiesWithCrossReference() {
219220
assertThat(runtimeHints.reflection().typeHints())
220221
.anySatisfy(javaBeanBinding(SamplePropertiesWithCrossReference.class))
221222
.anySatisfy(javaBeanBinding(CrossReferenceA.class)).anySatisfy(javaBeanBinding(CrossReferenceB.class))
222-
.hasSize(4);
223+
.hasSize(3);
223224
}
224225

225226
@Test

0 commit comments

Comments
 (0)