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
This commit is contained in:
@@ -25,11 +25,9 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.core.SpringProperties;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.TestContextAnnotationUtils.AnnotationDescriptor;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* {@code BootstrapUtils} is a collection of utility methods to assist with
|
||||
@@ -68,12 +66,8 @@ public abstract class BootstrapUtils {
|
||||
|
||||
/**
|
||||
* Create the {@code BootstrapContext} for the specified {@linkplain Class test class}.
|
||||
* <p>Uses reflection to create a {@link org.springframework.test.context.support.DefaultBootstrapContext}
|
||||
* that uses a default {@link CacheAwareContextLoaderDelegate} — configured
|
||||
* via the {@link CacheAwareContextLoaderDelegate#DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_PROPERTY_NAME}
|
||||
* system property or falling back to the
|
||||
* {@link org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate}
|
||||
* if the system property is not defined.
|
||||
* <p>Uses reflection to create a {@link org.springframework.test.context.support.DefaultBootstrapContext}.
|
||||
* that uses a {@link org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate}.
|
||||
* @param testClass the test class for which the bootstrap context should be created
|
||||
* @return a new {@code BootstrapContext}; never {@code null}
|
||||
*/
|
||||
@@ -98,21 +92,18 @@ public abstract class BootstrapUtils {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static CacheAwareContextLoaderDelegate createCacheAwareContextLoaderDelegate() {
|
||||
String className = SpringProperties.getProperty(
|
||||
CacheAwareContextLoaderDelegate.DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_PROPERTY_NAME);
|
||||
className = (StringUtils.hasText(className) ? className.trim() :
|
||||
DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_CLASS_NAME);
|
||||
Class<? extends CacheAwareContextLoaderDelegate> clazz = null;
|
||||
try {
|
||||
Class<? extends CacheAwareContextLoaderDelegate> clazz =
|
||||
(Class<? extends CacheAwareContextLoaderDelegate>) ClassUtils.forName(
|
||||
className, BootstrapUtils.class.getClassLoader());
|
||||
clazz = (Class<? extends CacheAwareContextLoaderDelegate>) ClassUtils.forName(
|
||||
DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_CLASS_NAME, BootstrapUtils.class.getClassLoader());
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("Instantiating CacheAwareContextLoaderDelegate from class [%s]", className));
|
||||
logger.debug(String.format("Instantiating CacheAwareContextLoaderDelegate from class [%s]",
|
||||
clazz.getName()));
|
||||
}
|
||||
return BeanUtils.instantiateClass(clazz, CacheAwareContextLoaderDelegate.class);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalStateException("Could not create CacheAwareContextLoaderDelegate [" + className + "]", ex);
|
||||
throw new IllegalStateException("Could not load CacheAwareContextLoaderDelegate [" + clazz + "]", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,20 +36,6 @@ import org.springframework.test.annotation.DirtiesContext.HierarchyMode;
|
||||
*/
|
||||
public interface CacheAwareContextLoaderDelegate {
|
||||
|
||||
/**
|
||||
* System property used to configure the fully qualified class name of the
|
||||
* default {@code CacheAwareContextLoaderDelegate}.
|
||||
* <p>May alternatively be configured via the
|
||||
* {@link org.springframework.core.SpringProperties} mechanism.
|
||||
* <p>If this property is not defined, the
|
||||
* {@link org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate
|
||||
* DefaultCacheAwareContextLoaderDelegate} will be used as the default.
|
||||
* @since 5.3.11
|
||||
*/
|
||||
String DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_PROPERTY_NAME =
|
||||
"spring.test.context.default.CacheAwareContextLoaderDelegate";
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the {@linkplain ApplicationContext application context} for
|
||||
* the supplied {@link MergedContextConfiguration} has been loaded (i.e.,
|
||||
|
||||
Reference in New Issue
Block a user