Skip to content

Commit 5fa9460

Browse files
committed
Temporarily revert changes for gh-33616
See gh-33616
1 parent 5d49268 commit 5fa9460

File tree

13 files changed

+18
-931
lines changed

13 files changed

+18
-931
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
import org.springframework.core.type.AnnotationMetadata;
8484
import org.springframework.core.type.MethodMetadata;
8585
import org.springframework.core.type.classreading.MetadataReaderFactory;
86+
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory;
8687
import org.springframework.javapoet.ClassName;
8788
import org.springframework.javapoet.CodeBlock;
8889
import org.springframework.lang.Nullable;
@@ -283,7 +284,7 @@ public void setBeanFactory(BeanFactory beanFactory) {
283284
"AutowiredAnnotationBeanPostProcessor requires a ConfigurableListableBeanFactory: " + beanFactory);
284285
}
285286
this.beanFactory = clbf;
286-
this.metadataReaderFactory = MetadataReaderFactory.create(clbf.getBeanClassLoader());
287+
this.metadataReaderFactory = new SimpleMetadataReaderFactory(clbf.getBeanClassLoader());
287288
}
288289

289290

spring-core/spring-core.gradle

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ apply plugin: "kotlin"
1111
apply plugin: "kotlinx-serialization"
1212

1313
multiRelease {
14-
targetVersions 17, 21, 24
14+
targetVersions 17, 21
1515
}
1616

1717
def javapoetVersion = "1.13.0"
@@ -25,10 +25,6 @@ configurations {
2525
graalvm
2626
}
2727

28-
springFramework {
29-
enableJavaPreviewFeatures = true
30-
}
31-
3228
task javapoetRepackJar(type: ShadowJar) {
3329
archiveBaseName = 'spring-javapoet-repack'
3430
archiveVersion = javapoetVersion

spring-core/src/main/java/org/springframework/core/type/classreading/CachingMetadataReaderFactory.java

+9-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -35,13 +35,11 @@
3535
* @author Costin Leau
3636
* @since 2.5
3737
*/
38-
public class CachingMetadataReaderFactory implements MetadataReaderFactory {
38+
public class CachingMetadataReaderFactory extends SimpleMetadataReaderFactory {
3939

4040
/** Default maximum number of entries for a local MetadataReader cache: 256. */
4141
public static final int DEFAULT_CACHE_LIMIT = 256;
4242

43-
private final MetadataReaderFactory delegate;
44-
4543
/** MetadataReader cache: either local or shared at the ResourceLoader level. */
4644
@Nullable
4745
private Map<Resource, MetadataReader> metadataReaderCache;
@@ -52,7 +50,7 @@ public class CachingMetadataReaderFactory implements MetadataReaderFactory {
5250
* using a local resource cache.
5351
*/
5452
public CachingMetadataReaderFactory() {
55-
this.delegate = MetadataReaderFactory.create((ClassLoader) null);
53+
super();
5654
setCacheLimit(DEFAULT_CACHE_LIMIT);
5755
}
5856

@@ -62,7 +60,7 @@ public CachingMetadataReaderFactory() {
6260
* @param classLoader the ClassLoader to use
6361
*/
6462
public CachingMetadataReaderFactory(@Nullable ClassLoader classLoader) {
65-
this.delegate = MetadataReaderFactory.create(classLoader);
63+
super(classLoader);
6664
setCacheLimit(DEFAULT_CACHE_LIMIT);
6765
}
6866

@@ -74,7 +72,7 @@ public CachingMetadataReaderFactory(@Nullable ClassLoader classLoader) {
7472
* @see DefaultResourceLoader#getResourceCache
7573
*/
7674
public CachingMetadataReaderFactory(@Nullable ResourceLoader resourceLoader) {
77-
this.delegate = MetadataReaderFactory.create(resourceLoader);
75+
super(resourceLoader);
7876
if (resourceLoader instanceof DefaultResourceLoader defaultResourceLoader) {
7977
this.metadataReaderCache = defaultResourceLoader.getResourceCache(MetadataReader.class);
8078
}
@@ -83,6 +81,7 @@ public CachingMetadataReaderFactory(@Nullable ResourceLoader resourceLoader) {
8381
}
8482
}
8583

84+
8685
/**
8786
* Specify the maximum number of entries for the MetadataReader cache.
8887
* <p>Default is 256 for a local cache, whereas a shared cache is
@@ -113,18 +112,14 @@ public int getCacheLimit() {
113112
}
114113
}
115114

116-
@Override
117-
public MetadataReader getMetadataReader(String className) throws IOException {
118-
return this.delegate.getMetadataReader(className);
119-
}
120115

121116
@Override
122117
public MetadataReader getMetadataReader(Resource resource) throws IOException {
123118
if (this.metadataReaderCache instanceof ConcurrentMap) {
124119
// No synchronization necessary...
125120
MetadataReader metadataReader = this.metadataReaderCache.get(resource);
126121
if (metadataReader == null) {
127-
metadataReader = this.delegate.getMetadataReader(resource);
122+
metadataReader = super.getMetadataReader(resource);
128123
this.metadataReaderCache.put(resource, metadataReader);
129124
}
130125
return metadataReader;
@@ -133,14 +128,14 @@ else if (this.metadataReaderCache != null) {
133128
synchronized (this.metadataReaderCache) {
134129
MetadataReader metadataReader = this.metadataReaderCache.get(resource);
135130
if (metadataReader == null) {
136-
metadataReader = this.delegate.getMetadataReader(resource);
131+
metadataReader = super.getMetadataReader(resource);
137132
this.metadataReaderCache.put(resource, metadataReader);
138133
}
139134
return metadataReader;
140135
}
141136
}
142137
else {
143-
return this.delegate.getMetadataReader(resource);
138+
return super.getMetadataReader(resource);
144139
}
145140
}
146141

spring-core/src/main/java/org/springframework/core/type/classreading/MetadataReaderFactory.java

+1-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -19,15 +19,12 @@
1919
import java.io.IOException;
2020

2121
import org.springframework.core.io.Resource;
22-
import org.springframework.core.io.ResourceLoader;
23-
import org.springframework.lang.Nullable;
2422

2523
/**
2624
* Factory interface for {@link MetadataReader} instances.
2725
* Allows for caching a MetadataReader per original resource.
2826
*
2927
* @author Juergen Hoeller
30-
* @author Brian Clozel
3128
* @since 2.5
3229
* @see SimpleMetadataReaderFactory
3330
* @see CachingMetadataReaderFactory
@@ -52,23 +49,4 @@ public interface MetadataReaderFactory {
5249
*/
5350
MetadataReader getMetadataReader(Resource resource) throws IOException;
5451

55-
/**
56-
* Create a default {@link MetadataReaderFactory} implementation that's suitable
57-
* for the current JVM.
58-
* @return a new factory instance
59-
* @since 7.0
60-
*/
61-
static MetadataReaderFactory create(@Nullable ResourceLoader resourceLoader) {
62-
return MetadataReaderFactoryDelegate.create(resourceLoader);
63-
}
64-
65-
/**
66-
* Create a default {@link MetadataReaderFactory} implementation that's suitable
67-
* for the current JVM.
68-
* @return a new factory instance
69-
* @since 7.0
70-
*/
71-
static MetadataReaderFactory create(@Nullable ClassLoader classLoader) {
72-
return MetadataReaderFactoryDelegate.create(classLoader);
73-
}
7452
}

spring-core/src/main/java/org/springframework/core/type/classreading/MetadataReaderFactoryDelegate.java

-39
This file was deleted.

spring-core/src/main/java24/org/springframework/core/type/classreading/ClassFileAnnotationMetadata.java

-129
This file was deleted.

0 commit comments

Comments
 (0)