diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java b/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java index d62fc5d83b07..2d39e2ef096c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java @@ -71,7 +71,6 @@ import org.springframework.beans.propertyeditors.URLEditor; import org.springframework.beans.propertyeditors.UUIDEditor; import org.springframework.beans.propertyeditors.ZoneIdEditor; -import org.springframework.core.SpringProperties; import org.springframework.core.convert.ConversionService; import org.springframework.core.io.Resource; import org.springframework.core.io.support.ResourceArrayPropertyEditor; @@ -93,14 +92,6 @@ */ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { - /** - * 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. - *
The default is "false". - */ - private static final boolean shouldIgnoreXml = SpringProperties.getFlag("spring.xml.ignore"); - - @Nullable private ConversionService conversionService; @@ -218,9 +209,7 @@ private void createDefaultEditors() { this.defaultEditors.put(Currency.class, new CurrencyEditor()); this.defaultEditors.put(File.class, new FileEditor()); this.defaultEditors.put(InputStream.class, new InputStreamEditor()); - if (!shouldIgnoreXml) { - this.defaultEditors.put(InputSource.class, new InputSourceEditor()); - } + this.defaultEditors.put(InputSource.class, new InputSourceEditor()); this.defaultEditors.put(Locale.class, new LocaleEditor()); this.defaultEditors.put(Path.class, new PathEditor()); this.defaultEditors.put(Pattern.class, new PatternEditor()); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java index b12483a86102..e85e080a3d3e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java @@ -35,8 +35,8 @@ import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.core.io.Resource; import org.springframework.core.io.support.EncodedResource; -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; @@ -148,7 +148,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader @Nullable private String defaultParentBean; - private PropertiesPersister propertiesPersister = ResourcePropertiesPersister.INSTANCE; + private PropertiesPersister propertiesPersister = DefaultPropertiesPersister.INSTANCE; /** @@ -187,12 +187,12 @@ public String getDefaultParentBean() { /** * Set the PropertiesPersister to use for parsing properties files. - * The default is ResourcePropertiesPersister. - * @see ResourcePropertiesPersister#INSTANCE + * 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); } /** diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java index 93f22542f6b5..66df6f8bcfc9 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java @@ -43,7 +43,6 @@ 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. - *
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 @@ private void loadBeanDefinitionsFromImportedResources( // 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; diff --git a/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java b/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java index 70c302fd024d..16a1640fd12b 100644 --- a/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java @@ -40,7 +40,6 @@ 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 @@ 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. - *
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 diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java index 3c8b5c8aab4c..be2a0c34150d 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java @@ -69,7 +69,6 @@ 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. - *
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 @@ protected ConfigurableListableBeanFactory obtainFreshBeanFactory() { 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. diff --git a/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java index 329cb743cf3c..8c809648a063 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java @@ -33,8 +33,8 @@ 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 @@ * @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 void setConcurrentRefresh(boolean concurrentRefresh) { /** * Set the PropertiesPersister to use for parsing properties files. - *
The default is ResourcePropertiesPersister. - * @see ResourcePropertiesPersister#INSTANCE + *
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); } /** diff --git a/spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java b/spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java index 0f33f9bfaf9b..a02c9460333a 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java @@ -28,6 +28,7 @@ import org.springframework.core.io.Resource; import org.springframework.lang.Nullable; import org.springframework.util.CollectionUtils; +import org.springframework.util.DefaultPropertiesPersister; import org.springframework.util.PropertiesPersister; /** @@ -56,7 +57,7 @@ public abstract class PropertiesLoaderSupport { @Nullable private String fileEncoding; - private PropertiesPersister propertiesPersister = ResourcePropertiesPersister.INSTANCE; + private PropertiesPersister propertiesPersister = DefaultPropertiesPersister.INSTANCE; /** @@ -130,12 +131,12 @@ public void setFileEncoding(String encoding) { /** * Set the PropertiesPersister to use for parsing properties files. - * The default is ResourcePropertiesPersister. - * @see ResourcePropertiesPersister#INSTANCE + * 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); } diff --git a/spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderUtils.java b/spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderUtils.java index a464f6b3de54..85fe14691beb 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderUtils.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderUtils.java @@ -24,11 +24,11 @@ import java.util.Enumeration; import java.util.Properties; -import org.springframework.core.SpringProperties; import org.springframework.core.io.Resource; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; +import org.springframework.util.DefaultPropertiesPersister; import org.springframework.util.PropertiesPersister; import org.springframework.util.ResourceUtils; @@ -49,13 +49,6 @@ public abstract class PropertiesLoaderUtils { private static final String XML_FILE_EXTENSION = ".xml"; - /** - * 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. - *
The default is "false". - */ - private static final boolean shouldIgnoreXml = SpringProperties.getFlag("spring.xml.ignore"); - /** * Load properties from the given EncodedResource, @@ -78,7 +71,7 @@ public static Properties loadProperties(EncodedResource resource) throws IOExcep public static void fillProperties(Properties props, EncodedResource resource) throws IOException { - fillProperties(props, resource, ResourcePropertiesPersister.INSTANCE); + fillProperties(props, resource, DefaultPropertiesPersister.INSTANCE); } /** @@ -96,9 +89,6 @@ static void fillProperties(Properties props, EncodedResource resource, Propertie try { String filename = resource.getResource().getFilename(); if (filename != null && filename.endsWith(XML_FILE_EXTENSION)) { - if (shouldIgnoreXml) { - throw new UnsupportedOperationException("XML support disabled"); - } stream = resource.getInputStream(); persister.loadFromXml(props, stream); } @@ -144,9 +134,6 @@ public static void fillProperties(Properties props, Resource resource) throws IO try (InputStream is = resource.getInputStream()) { String filename = resource.getFilename(); if (filename != null && filename.endsWith(XML_FILE_EXTENSION)) { - if (shouldIgnoreXml) { - throw new UnsupportedOperationException("XML support disabled"); - } props.loadFromXML(is); } else { @@ -194,9 +181,6 @@ public static Properties loadAllProperties(String resourceName, @Nullable ClassL ResourceUtils.useCachesIfNecessary(con); try (InputStream is = con.getInputStream()) { if (resourceName.endsWith(XML_FILE_EXTENSION)) { - if (shouldIgnoreXml) { - throw new UnsupportedOperationException("XML support disabled"); - } props.loadFromXML(is); } else { diff --git a/spring-core/src/main/java/org/springframework/core/io/support/ResourcePropertiesPersister.java b/spring-core/src/main/java/org/springframework/core/io/support/ResourcePropertiesPersister.java deleted file mode 100644 index 1388c1c175a2..000000000000 --- a/spring-core/src/main/java/org/springframework/core/io/support/ResourcePropertiesPersister.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2002-2020 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.core.io.support; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Properties; - -import org.springframework.core.SpringProperties; -import org.springframework.util.DefaultPropertiesPersister; - -/** - * Spring-aware subclass of the plain {@link DefaultPropertiesPersister}, - * adding a conditional check for disabled XML support through the shared - * "spring.xml.ignore" property. - * - *
This is the standard implementation used in Spring's resource support. - * - * @author Juergen Hoeller - * @author Sebastien Deleuze - * @since 5.3 - */ -public class ResourcePropertiesPersister extends DefaultPropertiesPersister { - - /** - * A convenient constant for a default {@code ResourcePropertiesPersister} instance, - * as used in Spring's common resource support. - * @since 5.3 - */ - public static final ResourcePropertiesPersister INSTANCE = new ResourcePropertiesPersister(); - - /** - * 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. - *
The default is "false". - */ - private static final boolean shouldIgnoreXml = SpringProperties.getFlag("spring.xml.ignore"); - - - @Override - public void loadFromXml(Properties props, InputStream is) throws IOException { - if (shouldIgnoreXml) { - throw new UnsupportedOperationException("XML support disabled"); - } - super.loadFromXml(props, is); - } - - @Override - public void storeToXml(Properties props, OutputStream os, String header) throws IOException { - if (shouldIgnoreXml) { - throw new UnsupportedOperationException("XML support disabled"); - } - super.storeToXml(props, os, header); - } - - @Override - public void storeToXml(Properties props, OutputStream os, String header, String encoding) throws IOException { - if (shouldIgnoreXml) { - throw new UnsupportedOperationException("XML support disabled"); - } - super.storeToXml(props, os, header, encoding); - } - -} diff --git a/spring-core/src/main/java/org/springframework/util/DefaultPropertiesPersister.java b/spring-core/src/main/java/org/springframework/util/DefaultPropertiesPersister.java index d0f3bc296f7d..cd885e3528b3 100644 --- a/spring-core/src/main/java/org/springframework/util/DefaultPropertiesPersister.java +++ b/spring-core/src/main/java/org/springframework/util/DefaultPropertiesPersister.java @@ -46,14 +46,22 @@ * "defaultEncoding" and "fileEncodings" properties). * * @author Juergen Hoeller + * @author Sebastien Deleuze * @since 10.03.2004 * @see java.util.Properties * @see java.util.Properties#load * @see java.util.Properties#store - * @see org.springframework.core.io.support.ResourcePropertiesPersister */ public class DefaultPropertiesPersister implements PropertiesPersister { + /** + * A convenient constant for a default {@code DefaultPropertiesPersister} instance, + * as used in Spring's common resource support. + * @since 6.0 + */ + public static final DefaultPropertiesPersister INSTANCE = new DefaultPropertiesPersister(); + + @Override public void load(Properties props, InputStream is) throws IOException { props.load(is); diff --git a/spring-core/src/main/java/org/springframework/util/PropertiesPersister.java b/spring-core/src/main/java/org/springframework/util/PropertiesPersister.java index 6b6fcfd38a27..0c8248dc7469 100644 --- a/spring-core/src/main/java/org/springframework/util/PropertiesPersister.java +++ b/spring-core/src/main/java/org/springframework/util/PropertiesPersister.java @@ -35,7 +35,6 @@ * @author Juergen Hoeller * @since 10.03.2004 * @see DefaultPropertiesPersister - * @see org.springframework.core.io.support.ResourcePropertiesPersister * @see java.util.Properties */ public interface PropertiesPersister { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java index 00869ece51b1..45452f0bcdeb 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java @@ -28,7 +28,6 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.core.SpringProperties; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.lang.Nullable; @@ -67,13 +66,6 @@ public class SQLErrorCodesFactory { private static final Log logger = LogFactory.getLog(SQLErrorCodesFactory.class); - /** - * 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. - *
The default is "false".
- */
- private static final boolean shouldIgnoreXml = SpringProperties.getFlag("spring.xml.ignore");
-
/**
* Keep track of a single instance so we can return it to classes that request it.
*/
@@ -109,9 +101,6 @@ public static SQLErrorCodesFactory getInstance() {
* @see #loadResource(String)
*/
protected SQLErrorCodesFactory() {
- if (shouldIgnoreXml) {
- throw new UnsupportedOperationException("XML support disabled");
- }
Map The default is "false".
- */
- private static final boolean shouldIgnoreXml = SpringProperties.getFlag("spring.xml.ignore");
-
static final boolean jackson2Present;
private static final boolean jackson2SmilePresent;
@@ -475,7 +467,7 @@ else if (codec instanceof EncoderHttpMessageWriter) {
((AbstractJackson2Decoder) codec).setMaxInMemorySize(size);
}
}
- if (jaxb2Present && !shouldIgnoreXml) {
+ if (jaxb2Present) {
if (codec instanceof Jaxb2XmlDecoder) {
((Jaxb2XmlDecoder) codec).setMaxInMemorySize(size);
}
@@ -578,7 +570,7 @@ protected void initObjectReaders() {
addCodec(this.objectReaders, new DecoderHttpMessageReader<>(this.jackson2SmileDecoder != null ?
(Jackson2SmileDecoder) this.jackson2SmileDecoder : new Jackson2SmileDecoder()));
}
- if (jaxb2Present && !shouldIgnoreXml) {
+ if (jaxb2Present) {
addCodec(this.objectReaders, new DecoderHttpMessageReader<>(this.jaxb2Decoder != null ?
(Jaxb2XmlDecoder) this.jaxb2Decoder : new Jaxb2XmlDecoder()));
}
@@ -702,7 +694,7 @@ final List The default is "false".
- */
- private static final boolean shouldIgnoreXml = SpringProperties.getFlag("spring.xml.ignore");
-
private static final boolean jaxb2Present;
private static final boolean jackson2Present;
@@ -82,17 +74,16 @@ public class AllEncompassingFormHttpMessageConverter extends FormHttpMessageConv
public AllEncompassingFormHttpMessageConverter() {
- if (!shouldIgnoreXml) {
- try {
- addPartConverter(new SourceHttpMessageConverter<>());
- }
- catch (Error err) {
- // Ignore when no TransformerFactory implementation is available
- }
-
- if (jaxb2Present && !jackson2XmlPresent) {
- addPartConverter(new Jaxb2RootElementHttpMessageConverter());
- }
+
+ try {
+ addPartConverter(new SourceHttpMessageConverter<>());
+ }
+ catch (Error err) {
+ // Ignore when no TransformerFactory implementation is available
+ }
+
+ if (jaxb2Present && !jackson2XmlPresent) {
+ addPartConverter(new Jaxb2RootElementHttpMessageConverter());
}
if (kotlinSerializationJsonPresent) {
@@ -108,7 +99,7 @@ else if (jsonbPresent) {
addPartConverter(new JsonbHttpMessageConverter());
}
- if (jackson2XmlPresent && !shouldIgnoreXml) {
+ if (jackson2XmlPresent) {
addPartConverter(new MappingJackson2XmlHttpMessageConverter());
}
diff --git a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java
index 1152f452d4d8..bf68ae3cf409 100644
--- a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java
+++ b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java
@@ -33,7 +33,6 @@
import io.micrometer.observation.ObservationRegistry;
import org.springframework.core.ParameterizedTypeReference;
-import org.springframework.core.SpringProperties;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@@ -104,13 +103,6 @@
*/
public class RestTemplate extends InterceptingHttpAccessor implements RestOperations {
- /**
- * 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.
- * The default is "false".
- */
- private static final boolean shouldIgnoreXml = SpringProperties.getFlag("spring.xml.ignore");
-
private static final boolean romePresent;
private static final boolean jaxb2Present;
@@ -174,14 +166,14 @@ public RestTemplate() {
this.messageConverters.add(new ByteArrayHttpMessageConverter());
this.messageConverters.add(new StringHttpMessageConverter());
this.messageConverters.add(new ResourceHttpMessageConverter(false));
- if (!shouldIgnoreXml) {
- try {
- this.messageConverters.add(new SourceHttpMessageConverter<>());
- }
- catch (Error err) {
- // Ignore when no TransformerFactory implementation is available
- }
+
+ try {
+ this.messageConverters.add(new SourceHttpMessageConverter<>());
+ }
+ catch (Error err) {
+ // Ignore when no TransformerFactory implementation is available
}
+
this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());
if (romePresent) {
@@ -189,13 +181,11 @@ public RestTemplate() {
this.messageConverters.add(new RssChannelHttpMessageConverter());
}
- if (!shouldIgnoreXml) {
- if (jackson2XmlPresent) {
- this.messageConverters.add(new MappingJackson2XmlHttpMessageConverter());
- }
- else if (jaxb2Present) {
- this.messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
- }
+ if (jackson2XmlPresent) {
+ this.messageConverters.add(new MappingJackson2XmlHttpMessageConverter());
+ }
+ else if (jaxb2Present) {
+ this.messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
}
if (kotlinSerializationProtobufPresent) {
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java
index 80647f21c86c..9a3f5da09dea 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java
@@ -33,7 +33,6 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
-import org.springframework.core.SpringProperties;
import org.springframework.core.convert.converter.Converter;
import org.springframework.format.Formatter;
import org.springframework.format.FormatterRegistry;
@@ -190,13 +189,6 @@
*/
public class WebMvcConfigurationSupport implements ApplicationContextAware, ServletContextAware {
- /**
- * 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.
- * The default is "false".
- */
- private static final boolean shouldIgnoreXml = SpringProperties.getFlag("spring.xml.ignore");
-
private static final boolean romePresent;
private static final boolean jaxb2Present;
@@ -460,7 +452,7 @@ protected Map The default is "false".
- */
- private static final boolean shouldIgnoreXml = SpringProperties.getFlag("spring.xml.ignore");
-
-
@Nullable
private List The default is "false".
- */
- private static final boolean shouldIgnoreXml = SpringProperties.getFlag("spring.xml.ignore");
-
/**
* MethodFilter that matches {@link InitBinder @InitBinder} methods.
*/
@@ -576,14 +568,13 @@ private void initMessageConverters() {
}
this.messageConverters.add(new ByteArrayHttpMessageConverter());
this.messageConverters.add(new StringHttpMessageConverter());
- if (!shouldIgnoreXml) {
- try {
- this.messageConverters.add(new SourceHttpMessageConverter<>());
- }
- catch (Error err) {
- // Ignore when no TransformerFactory implementation is available
- }
+ try {
+ this.messageConverters.add(new SourceHttpMessageConverter<>());
+ }
+ catch (Error err) {
+ // Ignore when no TransformerFactory implementation is available
}
+
this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());
}