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:
@@ -22,7 +22,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.springframework.core.SpringProperties;
|
||||
import org.springframework.core.codec.AbstractDataBufferDecoder;
|
||||
import org.springframework.core.codec.ByteArrayDecoder;
|
||||
import org.springframework.core.codec.ByteArrayEncoder;
|
||||
@@ -83,13 +82,6 @@ import org.springframework.util.ObjectUtils;
|
||||
*/
|
||||
class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigurer.DefaultCodecConfig {
|
||||
|
||||
/**
|
||||
* 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");
|
||||
|
||||
static final boolean jackson2Present;
|
||||
|
||||
private static final boolean jackson2SmilePresent;
|
||||
@@ -475,7 +467,7 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure
|
||||
((AbstractJackson2Decoder) codec).setMaxInMemorySize(size);
|
||||
}
|
||||
}
|
||||
if (jaxb2Present && !shouldIgnoreXml) {
|
||||
if (jaxb2Present) {
|
||||
if (codec instanceof Jaxb2XmlDecoder) {
|
||||
((Jaxb2XmlDecoder) codec).setMaxInMemorySize(size);
|
||||
}
|
||||
@@ -578,7 +570,7 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure
|
||||
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 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure
|
||||
addCodec(writers, new EncoderHttpMessageWriter<>(this.jackson2SmileEncoder != null ?
|
||||
(Jackson2SmileEncoder) this.jackson2SmileEncoder : new Jackson2SmileEncoder()));
|
||||
}
|
||||
if (jaxb2Present && !shouldIgnoreXml) {
|
||||
if (jaxb2Present) {
|
||||
addCodec(writers, new EncoderHttpMessageWriter<>(this.jaxb2Encoder != null ?
|
||||
(Jaxb2XmlEncoder) this.jaxb2Encoder : new Jaxb2XmlEncoder()));
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.http.converter.support;
|
||||
|
||||
import org.springframework.core.SpringProperties;
|
||||
import org.springframework.http.converter.FormHttpMessageConverter;
|
||||
import org.springframework.http.converter.cbor.KotlinSerializationCborHttpMessageConverter;
|
||||
import org.springframework.http.converter.json.GsonHttpMessageConverter;
|
||||
@@ -41,13 +40,6 @@ import org.springframework.util.ClassUtils;
|
||||
*/
|
||||
public class AllEncompassingFormHttpMessageConverter extends FormHttpMessageConverter {
|
||||
|
||||
/**
|
||||
* 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 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 @@ public class AllEncompassingFormHttpMessageConverter extends FormHttpMessageConv
|
||||
addPartConverter(new JsonbHttpMessageConverter());
|
||||
}
|
||||
|
||||
if (jackson2XmlPresent && !shouldIgnoreXml) {
|
||||
if (jackson2XmlPresent) {
|
||||
addPartConverter(new MappingJackson2XmlHttpMessageConverter());
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ import io.micrometer.observation.ObservationConvention;
|
||||
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 @@ import org.springframework.web.util.UriTemplateHandler;
|
||||
*/
|
||||
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.
|
||||
* <p>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 class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||
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 class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user