Remove spring.spel.ignore and spring.xml.ignore flags

This commit also removes ResourcePropertiesPersister which
was introduced in 5.3 specifically for spring.xml.ignore
flag and which is expected to be used only internally by
Spring Framework. DefaultPropertiesPersister should be used
instead.

Closes gh-29277
This commit is contained in:
Sébastien Deleuze
2022-10-10 09:13:38 +02:00
parent bca35dc0a2
commit 42c3ac64ff
19 changed files with 85 additions and 300 deletions

View File

@@ -43,7 +43,6 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.annotation.ConfigurationCondition.ConfigurationPhase;
import org.springframework.core.SpringProperties;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.env.Environment;
import org.springframework.core.io.Resource;
@@ -78,13 +77,6 @@ class ConfigurationClassBeanDefinitionReader {
private static final ScopeMetadataResolver scopeMetadataResolver = new AnnotationScopeMetadataResolver();
/**
* Boolean flag controlled by a {@code spring.xml.ignore} system property that instructs Spring to
* ignore XML, i.e. to not initialize the XML-related infrastructure.
* <p>The default is "false".
*/
private static final boolean shouldIgnoreXml = SpringProperties.getFlag("spring.xml.ignore");
private final BeanDefinitionRegistry registry;
private final SourceExtractor sourceExtractor;
@@ -347,9 +339,6 @@ class ConfigurationClassBeanDefinitionReader {
// When clearly asking for Groovy, that's what they'll get...
readerClass = GroovyBeanDefinitionReader.class;
}
else if (shouldIgnoreXml) {
throw new UnsupportedOperationException("XML support disabled");
}
else {
// Primarily ".xml" files but for any other extension as well
readerClass = XmlBeanDefinitionReader.class;

View File

@@ -40,7 +40,6 @@ import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.MethodIntrospector;
import org.springframework.core.SpringProperties;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.annotation.AnnotationUtils;
@@ -65,14 +64,6 @@ import org.springframework.util.CollectionUtils;
public class EventListenerMethodProcessor
implements SmartInitializingSingleton, ApplicationContextAware, BeanFactoryPostProcessor {
/**
* Boolean flag controlled by a {@code spring.spel.ignore} system property that instructs Spring to
* ignore SpEL, i.e. to not initialize the SpEL infrastructure.
* <p>The default is "false".
*/
private static final boolean shouldIgnoreSpel = SpringProperties.getFlag("spring.spel.ignore");
protected final Log logger = LogFactory.getLog(getClass());
@Nullable
@@ -91,12 +82,7 @@ public class EventListenerMethodProcessor
public EventListenerMethodProcessor() {
if (shouldIgnoreSpel) {
this.evaluator = null;
}
else {
this.evaluator = new EventExpressionEvaluator();
}
this.evaluator = new EventExpressionEvaluator();
}
@Override

View File

@@ -69,7 +69,6 @@ import org.springframework.context.weaving.LoadTimeWeaverAware;
import org.springframework.context.weaving.LoadTimeWeaverAwareProcessor;
import org.springframework.core.NativeDetector;
import org.springframework.core.ResolvableType;
import org.springframework.core.SpringProperties;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.env.ConfigurableEnvironment;
@@ -159,13 +158,6 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
*/
public static final String APPLICATION_EVENT_MULTICASTER_BEAN_NAME = "applicationEventMulticaster";
/**
* Boolean flag controlled by a {@code spring.spel.ignore} system property that instructs Spring to
* ignore SpEL, i.e. to not initialize the SpEL infrastructure.
* <p>The default is "false".
*/
private static final boolean shouldIgnoreSpel = SpringProperties.getFlag("spring.spel.ignore");
static {
// Eagerly load the ContextClosedEvent class to avoid weird classloader issues
@@ -689,9 +681,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
protected void prepareBeanFactory(ConfigurableListableBeanFactory beanFactory) {
// Tell the internal bean factory to use the context's class loader etc.
beanFactory.setBeanClassLoader(getClassLoader());
if (!shouldIgnoreSpel) {
beanFactory.setBeanExpressionResolver(new StandardBeanExpressionResolver(beanFactory.getBeanClassLoader()));
}
beanFactory.setBeanExpressionResolver(new StandardBeanExpressionResolver(beanFactory.getBeanClassLoader()));
beanFactory.addPropertyEditorRegistrar(new ResourceEditorRegistrar(this, getEnvironment()));
// Configure the bean factory with context callbacks.

View File

@@ -33,8 +33,8 @@ import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.ResourcePropertiesPersister;
import org.springframework.lang.Nullable;
import org.springframework.util.DefaultPropertiesPersister;
import org.springframework.util.PropertiesPersister;
import org.springframework.util.StringUtils;
@@ -80,7 +80,6 @@ import org.springframework.util.StringUtils;
* @see #setFileEncodings
* @see #setPropertiesPersister
* @see #setResourceLoader
* @see ResourcePropertiesPersister
* @see org.springframework.core.io.DefaultResourceLoader
* @see ResourceBundleMessageSource
* @see java.util.ResourceBundle
@@ -98,7 +97,7 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased
private boolean concurrentRefresh = true;
private PropertiesPersister propertiesPersister = ResourcePropertiesPersister.INSTANCE;
private PropertiesPersister propertiesPersister = DefaultPropertiesPersister.INSTANCE;
private ResourceLoader resourceLoader = new DefaultResourceLoader();
@@ -143,12 +142,12 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased
/**
* Set the PropertiesPersister to use for parsing properties files.
* <p>The default is ResourcePropertiesPersister.
* @see ResourcePropertiesPersister#INSTANCE
* <p>The default is {@code DefaultPropertiesPersister}.
* @see DefaultPropertiesPersister#INSTANCE
*/
public void setPropertiesPersister(@Nullable PropertiesPersister propertiesPersister) {
this.propertiesPersister =
(propertiesPersister != null ? propertiesPersister : ResourcePropertiesPersister.INSTANCE);
(propertiesPersister != null ? propertiesPersister : DefaultPropertiesPersister.INSTANCE);
}
/**