Skip to content

Commit 1bc82d2

Browse files
committed
Remove deprecation on CandidateComponentsIndex(Loader)
Closes gh-35472
1 parent 80e7ee3 commit 1bc82d2

File tree

8 files changed

+26
-28
lines changed

8 files changed

+26
-28
lines changed

spring-context-indexer/src/main/java/org/springframework/context/index/processor/CandidateComponentsIndexer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@
3737

3838
/**
3939
* Annotation {@link Processor} that writes a {@link CandidateComponentsMetadata}
40-
* file for spring components.
40+
* file for Spring components.
4141
*
4242
* @author Stephane Nicoll
4343
* @author Juergen Hoeller
4444
* @since 5.0
45-
* @deprecated as of 6.1, in favor of the AOT engine.
45+
* @deprecated as of 6.1, in favor of the AOT engine and the forthcoming
46+
* support for an AOT-generated Spring components index
4647
*/
4748
@Deprecated(since = "6.1", forRemoval = true)
4849
public class CandidateComponentsIndexer implements Processor {

spring-context-indexer/src/main/java/org/springframework/context/index/processor/StandardStereotypesProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
/**
2727
* A {@link StereotypesProvider} that extracts a stereotype for each
28-
* {@code jakarta.*} or {@code javax.*} annotation <i>present</i> on a class or
29-
* interface.
28+
* {@code jakarta.*} or {@code javax.*} annotation <i>present</i>
29+
* on a class or interface.
3030
*
3131
* @author Stephane Nicoll
3232
* @since 5.0

spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,9 @@ private Set<BeanDefinition> addCandidateComponentsFromIndex(CandidateComponentsI
452452
private Set<BeanDefinition> scanCandidateComponents(String basePackage) {
453453
Set<BeanDefinition> candidates = new LinkedHashSet<>();
454454
try {
455-
String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX +
455+
String packageSearchPattern = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX +
456456
resolveBasePackage(basePackage) + '/' + this.resourcePattern;
457-
Resource[] resources = getResourcePatternResolver().getResources(packageSearchPath);
457+
Resource[] resources = getResourcePatternResolver().getResources(packageSearchPattern);
458458
boolean traceEnabled = logger.isTraceEnabled();
459459
boolean debugEnabled = logger.isDebugEnabled();
460460
for (Resource resource : resources) {
@@ -537,13 +537,13 @@ protected String resolveBasePackage(String basePackage) {
537537
* @return whether the class qualifies as a candidate component
538538
*/
539539
protected boolean isCandidateComponent(MetadataReader metadataReader) throws IOException {
540-
for (TypeFilter tf : this.excludeFilters) {
541-
if (tf.match(metadataReader, getMetadataReaderFactory())) {
540+
for (TypeFilter filter : this.excludeFilters) {
541+
if (filter.match(metadataReader, getMetadataReaderFactory())) {
542542
return false;
543543
}
544544
}
545-
for (TypeFilter tf : this.includeFilters) {
546-
if (tf.match(metadataReader, getMetadataReaderFactory())) {
545+
for (TypeFilter filter : this.includeFilters) {
546+
if (filter.match(metadataReader, getMetadataReaderFactory())) {
547547
return isConditionMatch(metadataReader);
548548
}
549549
}

spring-context/src/main/java/org/springframework/context/index/CandidateComponentsIndex.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@
4545
*
4646
* @author Stephane Nicoll
4747
* @since 5.0
48-
* @deprecated as of 6.1, in favor of the AOT engine.
4948
*/
50-
@Deprecated(since = "6.1", forRemoval = true)
5149
public class CandidateComponentsIndex {
5250

5351
private static final AntPathMatcher pathMatcher = new AntPathMatcher(".");
@@ -83,7 +81,7 @@ private static MultiValueMap<String, Entry> parseIndex(List<Properties> content)
8381
public Set<String> getCandidateTypes(String basePackage, String stereotype) {
8482
List<Entry> candidates = this.index.get(stereotype);
8583
if (candidates != null) {
86-
return candidates.parallelStream()
84+
return candidates.stream()
8785
.filter(t -> t.match(basePackage))
8886
.map(t -> t.type)
8987
.collect(Collectors.toSet());
@@ -94,7 +92,7 @@ public Set<String> getCandidateTypes(String basePackage, String stereotype) {
9492

9593
private static class Entry {
9694

97-
private final String type;
95+
final String type;
9896

9997
private final String packageName;
10098

spring-context/src/main/java/org/springframework/context/index/CandidateComponentsIndexLoader.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@
3838
*
3939
* @author Stephane Nicoll
4040
* @since 5.0
41-
* @deprecated as of 6.1, in favor of the AOT engine.
4241
*/
43-
@Deprecated(since = "6.1", forRemoval = true)
44-
@SuppressWarnings("removal")
4542
public final class CandidateComponentsIndexLoader {
4643

4744
/**

spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ void testSimpleScanWithDefaultFiltersAndPostProcessors() {
6161
GenericApplicationContext context = new GenericApplicationContext();
6262
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
6363
int beanCount = scanner.scan(BASE_PACKAGE);
64+
6465
assertThat(beanCount).isGreaterThanOrEqualTo(12);
6566
assertThat(context.containsBean("serviceInvocationCounter")).isTrue();
6667
assertThat(context.containsBean("fooServiceImpl")).isTrue();
@@ -73,8 +74,8 @@ void testSimpleScanWithDefaultFiltersAndPostProcessors() {
7374
assertThat(context.containsBean(AnnotationConfigUtils.COMMON_ANNOTATION_PROCESSOR_BEAN_NAME)).isTrue();
7475
assertThat(context.containsBean(AnnotationConfigUtils.EVENT_LISTENER_PROCESSOR_BEAN_NAME)).isTrue();
7576
assertThat(context.containsBean(AnnotationConfigUtils.EVENT_LISTENER_FACTORY_BEAN_NAME)).isTrue();
76-
context.refresh();
7777

78+
context.refresh();
7879
FooServiceImpl fooService = context.getBean("fooServiceImpl", FooServiceImpl.class);
7980
assertThat(context.getDefaultListableBeanFactory().containsSingleton("myNamedComponent")).isTrue();
8081
assertThat(fooService.foo(123)).isEqualTo("bar");
@@ -157,6 +158,7 @@ void testDoubleScanWithIndex() {
157158

158159
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
159160
int beanCount = scanner.scan(BASE_PACKAGE);
161+
160162
assertThat(beanCount).isGreaterThanOrEqualTo(12);
161163

162164
ClassPathBeanDefinitionScanner scanner2 = new ClassPathBeanDefinitionScanner(context) {
@@ -182,8 +184,8 @@ void testSimpleScanWithDefaultFiltersAndNoPostProcessors() {
182184
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
183185
scanner.setIncludeAnnotationConfig(false);
184186
int beanCount = scanner.scan(BASE_PACKAGE);
185-
assertThat(beanCount).isGreaterThanOrEqualTo(7);
186187

188+
assertThat(beanCount).isGreaterThanOrEqualTo(7);
187189
assertThat(context.containsBean("serviceInvocationCounter")).isTrue();
188190
assertThat(context.containsBean("fooServiceImpl")).isTrue();
189191
assertThat(context.containsBean("stubFooDao")).isTrue();
@@ -482,12 +484,14 @@ void testBeanAutowiredWithAnnotationConfigEnabled() {
482484
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
483485
scanner.setBeanNameGenerator(new TestBeanNameGenerator());
484486
int beanCount = scanner.scan(BASE_PACKAGE);
487+
485488
assertThat(beanCount).isGreaterThanOrEqualTo(12);
486-
context.refresh();
487489

490+
context.refresh();
488491
FooServiceImpl fooService = context.getBean("fooService", FooServiceImpl.class);
489492
StaticListableBeanFactory myBf = (StaticListableBeanFactory) context.getBean("myBf");
490493
MessageSource ms = (MessageSource) context.getBean("messageSource");
494+
491495
assertThat(fooService.isInitCalled()).isTrue();
492496
assertThat(fooService.foo(123)).isEqualTo("bar");
493497
assertThat(fooService.lookupFoo(123)).isEqualTo("bar");
@@ -509,9 +513,10 @@ void testBeanNotAutowiredWithAnnotationConfigDisabled() {
509513
scanner.setIncludeAnnotationConfig(false);
510514
scanner.setBeanNameGenerator(new TestBeanNameGenerator());
511515
int beanCount = scanner.scan(BASE_PACKAGE);
516+
512517
assertThat(beanCount).isGreaterThanOrEqualTo(7);
513-
context.refresh();
514518

519+
context.refresh();
515520
try {
516521
context.getBean("fooService");
517522
}
@@ -545,9 +550,10 @@ void testAutowireCandidatePatternDoesNotMatch() {
545550
scanner.setAutowireCandidatePatterns("*NoSuchDao");
546551
scanner.scan(BASE_PACKAGE);
547552
context.refresh();
548-
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
549-
context.getBean("fooService"))
550-
.satisfies(ex -> assertThat(ex.getMostSpecificCause()).isInstanceOf(NoSuchBeanDefinitionException.class));
553+
assertThatExceptionOfType(BeanCreationException.class)
554+
.isThrownBy(() -> context.getBean("fooService"))
555+
.satisfies(ex ->
556+
assertThat(ex.getMostSpecificCause()).isInstanceOf(NoSuchBeanDefinitionException.class));
551557
}
552558

553559

spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
*
3333
* @author Stephane Nicoll
3434
*/
35-
@Deprecated
36-
@SuppressWarnings("removal")
3735
public class CandidateComponentsIndexLoaderTests {
3836

3937
@Test

spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
*
3131
* @author Stephane Nicoll
3232
*/
33-
@Deprecated
34-
@SuppressWarnings("removal")
3533
public class CandidateComponentsIndexTests {
3634

3735
@Test

0 commit comments

Comments
 (0)