Skip to content

Commit f1dd973

Browse files
committed
Merge pull request #16930 from dreis2211
* pr/16930: Fix deprecated StandardAnnotationMetadata usages
2 parents 9ba5c78 + 27ca7e1 commit f1dd973

File tree

5 files changed

+12
-16
lines changed

5 files changed

+12
-16
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextConfigurationImportSelectorTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
2626
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType;
2727
import org.springframework.core.annotation.Order;
28-
import org.springframework.core.type.StandardAnnotationMetadata;
28+
import org.springframework.core.type.AnnotationMetadata;
2929

3030
import static org.assertj.core.api.Assertions.assertThat;
3131

@@ -41,7 +41,7 @@ public class ManagementContextConfigurationImportSelectorTests {
4141
public void selectImportsShouldOrderResult() {
4242
String[] imports = new TestManagementContextConfigurationsImportSelector(C.class,
4343
A.class, D.class, B.class).selectImports(
44-
new StandardAnnotationMetadata(EnableChildContext.class));
44+
AnnotationMetadata.introspect(EnableChildContext.class));
4545
assertThat(imports).containsExactly(A.class.getName(), B.class.getName(),
4646
C.class.getName(), D.class.getName());
4747
}
@@ -50,7 +50,7 @@ public void selectImportsShouldOrderResult() {
5050
public void selectImportsFiltersChildOnlyConfigurationWhenUsingSameContext() {
5151
String[] imports = new TestManagementContextConfigurationsImportSelector(
5252
ChildOnly.class, SameOnly.class, A.class).selectImports(
53-
new StandardAnnotationMetadata(EnableSameContext.class));
53+
AnnotationMetadata.introspect(EnableSameContext.class));
5454
assertThat(imports).containsExactlyInAnyOrder(SameOnly.class.getName(),
5555
A.class.getName());
5656
}
@@ -59,7 +59,7 @@ public void selectImportsFiltersChildOnlyConfigurationWhenUsingSameContext() {
5959
public void selectImportsFiltersSameOnlyConfigurationWhenUsingChildContext() {
6060
String[] imports = new TestManagementContextConfigurationsImportSelector(
6161
ChildOnly.class, SameOnly.class, A.class).selectImports(
62-
new StandardAnnotationMetadata(EnableChildContext.class));
62+
AnnotationMetadata.introspect(EnableChildContext.class));
6363
assertThat(imports).containsExactlyInAnyOrder(ChildOnly.class.getName(),
6464
A.class.getName());
6565
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/AbstractRepositoryConfigurationSourceSupport.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.springframework.core.env.Environment;
3131
import org.springframework.core.io.ResourceLoader;
3232
import org.springframework.core.type.AnnotationMetadata;
33-
import org.springframework.core.type.StandardAnnotationMetadata;
3433
import org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource;
3534
import org.springframework.data.repository.config.BootstrapMode;
3635
import org.springframework.data.repository.config.RepositoryConfigurationDelegate;
@@ -66,8 +65,7 @@ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
6665

6766
private AnnotationRepositoryConfigurationSource getConfigurationSource(
6867
BeanDefinitionRegistry registry, BeanNameGenerator importBeanNameGenerator) {
69-
StandardAnnotationMetadata metadata = new StandardAnnotationMetadata(
70-
getConfiguration(), true);
68+
AnnotationMetadata metadata = AnnotationMetadata.introspect(getConfiguration());
7169
return new AutoConfiguredAnnotationRepositoryConfigurationSource(metadata,
7270
getAnnotation(), this.resourceLoader, this.environment, registry,
7371
importBeanNameGenerator) {

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationScanRegistrar.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@
2525
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
2626
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
2727
import org.springframework.core.type.AnnotationMetadata;
28-
import org.springframework.core.type.StandardAnnotationMetadata;
2928
import org.springframework.integration.annotation.IntegrationComponentScan;
3029
import org.springframework.integration.config.IntegrationComponentScanRegistrar;
3130

@@ -49,8 +48,8 @@ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
4948
@Override
5049
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
5150
final BeanDefinitionRegistry registry) {
52-
super.registerBeanDefinitions(new StandardAnnotationMetadata(
53-
IntegrationComponentScanConfiguration.class, true), registry);
51+
super.registerBeanDefinitions(AnnotationMetadata
52+
.introspect(IntegrationComponentScanConfiguration.class), registry);
5453
}
5554

5655
@Override

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelectorTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import org.springframework.context.annotation.Configuration;
3838
import org.springframework.core.io.DefaultResourceLoader;
3939
import org.springframework.core.io.support.SpringFactoriesLoader;
40-
import org.springframework.core.type.StandardAnnotationMetadata;
40+
import org.springframework.core.type.AnnotationMetadata;
4141
import org.springframework.mock.env.MockEnvironment;
4242

4343
import static org.assertj.core.api.Assertions.assertThat;
@@ -220,7 +220,7 @@ public void filterShouldSupportAware() {
220220
}
221221

222222
private String[] selectImports(Class<?> source) {
223-
return this.importSelector.selectImports(new StandardAnnotationMetadata(source));
223+
return this.importSelector.selectImports(AnnotationMetadata.introspect(source));
224224
}
225225

226226
private List<String> getAutoConfigurationClassNames() {

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import org.springframework.core.annotation.Order;
4747
import org.springframework.core.style.ToStringCreator;
4848
import org.springframework.core.type.AnnotationMetadata;
49-
import org.springframework.core.type.StandardAnnotationMetadata;
5049
import org.springframework.test.context.ContextCustomizer;
5150
import org.springframework.test.context.MergedContextConfiguration;
5251
import org.springframework.util.ReflectionUtils;
@@ -284,8 +283,8 @@ private boolean isIgnoredAnnotation(Annotation annotation) {
284283
private Set<Object> determineImports(Set<Annotation> annotations,
285284
Class<?> testClass) {
286285
Set<Object> determinedImports = new LinkedHashSet<>();
287-
AnnotationMetadata testClassMetadata = new StandardAnnotationMetadata(
288-
testClass);
286+
AnnotationMetadata testClassMetadata = AnnotationMetadata
287+
.introspect(testClass);
289288
for (Annotation annotation : annotations) {
290289
for (Class<?> source : getImports(annotation)) {
291290
Set<Object> determinedSourceImports = determineImports(source,

0 commit comments

Comments
 (0)