Skip to content

Commit 1e2541a

Browse files
committed
Remove support for setting default CacheAwareContextLoaderDelegate
The ability to set a system property to change the default CacheAwareContextLoaderDelegate was only needed by the Spring Native project in the Spring Framework 5.3.x line and should not be used by other projects. This commit therefore reverts the changes made in conjunction with gh-27540. Closes gh-29061
1 parent a711ed5 commit 1e2541a

File tree

3 files changed

+9
-127
lines changed

3 files changed

+9
-127
lines changed

spring-test/src/main/java/org/springframework/test/context/BootstrapUtils.java

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@
2525
import org.apache.commons.logging.LogFactory;
2626

2727
import org.springframework.beans.BeanUtils;
28-
import org.springframework.core.SpringProperties;
2928
import org.springframework.lang.Nullable;
3029
import org.springframework.test.context.TestContextAnnotationUtils.AnnotationDescriptor;
3130
import org.springframework.util.ClassUtils;
32-
import org.springframework.util.StringUtils;
3331

3432
/**
3533
* {@code BootstrapUtils} is a collection of utility methods to assist with
@@ -68,12 +66,8 @@ public abstract class BootstrapUtils {
6866

6967
/**
7068
* Create the {@code BootstrapContext} for the specified {@linkplain Class test class}.
71-
* <p>Uses reflection to create a {@link org.springframework.test.context.support.DefaultBootstrapContext}
72-
* that uses a default {@link CacheAwareContextLoaderDelegate} &mdash; configured
73-
* via the {@link CacheAwareContextLoaderDelegate#DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_PROPERTY_NAME}
74-
* system property or falling back to the
75-
* {@link org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate}
76-
* if the system property is not defined.
69+
* <p>Uses reflection to create a {@link org.springframework.test.context.support.DefaultBootstrapContext}.
70+
* that uses a {@link org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate}.
7771
* @param testClass the test class for which the bootstrap context should be created
7872
* @return a new {@code BootstrapContext}; never {@code null}
7973
*/
@@ -98,21 +92,18 @@ static BootstrapContext createBootstrapContext(Class<?> testClass) {
9892

9993
@SuppressWarnings("unchecked")
10094
private static CacheAwareContextLoaderDelegate createCacheAwareContextLoaderDelegate() {
101-
String className = SpringProperties.getProperty(
102-
CacheAwareContextLoaderDelegate.DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_PROPERTY_NAME);
103-
className = (StringUtils.hasText(className) ? className.trim() :
104-
DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_CLASS_NAME);
95+
Class<? extends CacheAwareContextLoaderDelegate> clazz = null;
10596
try {
106-
Class<? extends CacheAwareContextLoaderDelegate> clazz =
107-
(Class<? extends CacheAwareContextLoaderDelegate>) ClassUtils.forName(
108-
className, BootstrapUtils.class.getClassLoader());
97+
clazz = (Class<? extends CacheAwareContextLoaderDelegate>) ClassUtils.forName(
98+
DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_CLASS_NAME, BootstrapUtils.class.getClassLoader());
10999
if (logger.isDebugEnabled()) {
110-
logger.debug(String.format("Instantiating CacheAwareContextLoaderDelegate from class [%s]", className));
100+
logger.debug(String.format("Instantiating CacheAwareContextLoaderDelegate from class [%s]",
101+
clazz.getName()));
111102
}
112103
return BeanUtils.instantiateClass(clazz, CacheAwareContextLoaderDelegate.class);
113104
}
114105
catch (Throwable ex) {
115-
throw new IllegalStateException("Could not create CacheAwareContextLoaderDelegate [" + className + "]", ex);
106+
throw new IllegalStateException("Could not load CacheAwareContextLoaderDelegate [" + clazz + "]", ex);
116107
}
117108
}
118109

spring-test/src/main/java/org/springframework/test/context/CacheAwareContextLoaderDelegate.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 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.
@@ -36,20 +36,6 @@
3636
*/
3737
public interface CacheAwareContextLoaderDelegate {
3838

39-
/**
40-
* System property used to configure the fully qualified class name of the
41-
* default {@code CacheAwareContextLoaderDelegate}.
42-
* <p>May alternatively be configured via the
43-
* {@link org.springframework.core.SpringProperties} mechanism.
44-
* <p>If this property is not defined, the
45-
* {@link org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate
46-
* DefaultCacheAwareContextLoaderDelegate} will be used as the default.
47-
* @since 5.3.11
48-
*/
49-
String DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_PROPERTY_NAME =
50-
"spring.test.context.default.CacheAwareContextLoaderDelegate";
51-
52-
5339
/**
5440
* Determine if the {@linkplain ApplicationContext application context} for
5541
* the supplied {@link MergedContextConfiguration} has been loaded (i.e.,

spring-test/src/test/java/org/springframework/test/context/support/CustomDefaultCacheAwareContextLoaderDelegateTests.java

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)