Use uppercase for classpath-related static final field names

Closes gh-35525
This commit is contained in:
Sébastien Deleuze
2025-09-22 18:32:14 +02:00
parent 5ac3c40689
commit 7635ac38f6
76 changed files with 451 additions and 450 deletions
@@ -89,39 +89,39 @@ import org.springframework.util.ObjectUtils;
*/
class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigurer.DefaultCodecConfig {
static final boolean jacksonPresent;
static final boolean JACKSON_PRESENT;
static final boolean jackson2Present;
static final boolean JACKSON_2_PRESENT;
private static final boolean jacksonSmilePresent;
private static final boolean JACKSON_SMILE_PRESENT;
private static final boolean jackson2SmilePresent;
private static final boolean JACKSON_2_SMILE_PRESENT;
private static final boolean jaxb2Present;
private static final boolean JAXB_2_PRESENT;
private static final boolean protobufPresent;
private static final boolean PROTOBUF_PRESENT;
static final boolean nettyByteBufPresent;
static final boolean NETTY_BYTE_BUF_PRESENT;
static final boolean kotlinSerializationCborPresent;
static final boolean KOTLIN_SERIALIZATION_CBOR_PRESENT;
static final boolean kotlinSerializationJsonPresent;
static final boolean KOTLIN_SERIALIZATION_JSON_PRESENT;
static final boolean kotlinSerializationProtobufPresent;
static final boolean KOTLIN_SERIALIZATION_PROTOBUF_PRESENT;
static {
ClassLoader classLoader = BaseCodecConfigurer.class.getClassLoader();
jacksonPresent = ClassUtils.isPresent("tools.jackson.databind.ObjectMapper", classLoader);
jackson2Present = ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader) &&
JACKSON_PRESENT = ClassUtils.isPresent("tools.jackson.databind.ObjectMapper", classLoader);
JACKSON_2_PRESENT = ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader) &&
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator", classLoader);
jacksonSmilePresent = jacksonPresent && ClassUtils.isPresent("tools.jackson.dataformat.smile.SmileMapper", classLoader);
jackson2SmilePresent = jackson2Present && ClassUtils.isPresent("com.fasterxml.jackson.dataformat.smile.SmileFactory", classLoader);
jaxb2Present = ClassUtils.isPresent("jakarta.xml.bind.Binder", classLoader);
protobufPresent = ClassUtils.isPresent("com.google.protobuf.Message", classLoader);
nettyByteBufPresent = ClassUtils.isPresent("io.netty.buffer.ByteBuf", classLoader);
kotlinSerializationCborPresent = ClassUtils.isPresent("kotlinx.serialization.cbor.Cbor", classLoader);
kotlinSerializationJsonPresent = ClassUtils.isPresent("kotlinx.serialization.json.Json", classLoader);
kotlinSerializationProtobufPresent = ClassUtils.isPresent("kotlinx.serialization.protobuf.ProtoBuf", classLoader);
JACKSON_SMILE_PRESENT = JACKSON_PRESENT && ClassUtils.isPresent("tools.jackson.dataformat.smile.SmileMapper", classLoader);
JACKSON_2_SMILE_PRESENT = JACKSON_2_PRESENT && ClassUtils.isPresent("com.fasterxml.jackson.dataformat.smile.SmileFactory", classLoader);
JAXB_2_PRESENT = ClassUtils.isPresent("jakarta.xml.bind.Binder", classLoader);
PROTOBUF_PRESENT = ClassUtils.isPresent("com.google.protobuf.Message", classLoader);
NETTY_BYTE_BUF_PRESENT = ClassUtils.isPresent("io.netty.buffer.ByteBuf", classLoader);
KOTLIN_SERIALIZATION_CBOR_PRESENT = ClassUtils.isPresent("kotlinx.serialization.cbor.Cbor", classLoader);
KOTLIN_SERIALIZATION_JSON_PRESENT = ClassUtils.isPresent("kotlinx.serialization.json.Json", classLoader);
KOTLIN_SERIALIZATION_PROTOBUF_PRESENT = ClassUtils.isPresent("kotlinx.serialization.protobuf.ProtoBuf", classLoader);
}
@@ -448,12 +448,12 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure
addCodec(this.typedReaders, new DecoderHttpMessageReader<>(new ByteArrayDecoder()));
addCodec(this.typedReaders, new DecoderHttpMessageReader<>(new ByteBufferDecoder()));
addCodec(this.typedReaders, new DecoderHttpMessageReader<>(new DataBufferDecoder()));
if (nettyByteBufPresent) {
if (NETTY_BYTE_BUF_PRESENT) {
addCodec(this.typedReaders, new DecoderHttpMessageReader<>(new NettyByteBufDecoder()));
}
addCodec(this.typedReaders, new ResourceHttpMessageReader(new ResourceDecoder()));
addCodec(this.typedReaders, new DecoderHttpMessageReader<>(StringDecoder.textPlainOnly()));
if (protobufPresent) {
if (PROTOBUF_PRESENT) {
addCodec(this.typedReaders, new DecoderHttpMessageReader<>(this.protobufDecoder != null ?
(ProtobufDecoder) this.protobufDecoder : new ProtobufDecoder()));
}
@@ -506,37 +506,37 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure
}
// Pattern variables in the following if-blocks cannot be named the same as instance fields
// due to lacking support in Checkstyle: https://github.com/checkstyle/checkstyle/issues/10969
if (protobufPresent) {
if (PROTOBUF_PRESENT) {
if (codec instanceof ProtobufDecoder protobufDec) {
protobufDec.setMaxMessageSize(size);
}
}
if (kotlinSerializationCborPresent) {
if (KOTLIN_SERIALIZATION_CBOR_PRESENT) {
if (codec instanceof KotlinSerializationCborDecoder kotlinSerializationCborDec) {
kotlinSerializationCborDec.setMaxInMemorySize(size);
}
}
if (kotlinSerializationJsonPresent) {
if (KOTLIN_SERIALIZATION_JSON_PRESENT) {
if (codec instanceof KotlinSerializationJsonDecoder kotlinSerializationJsonDec) {
kotlinSerializationJsonDec.setMaxInMemorySize(size);
}
}
if (kotlinSerializationProtobufPresent) {
if (KOTLIN_SERIALIZATION_PROTOBUF_PRESENT) {
if (codec instanceof KotlinSerializationProtobufDecoder kotlinSerializationProtobufDec) {
kotlinSerializationProtobufDec.setMaxInMemorySize(size);
}
}
if (jacksonPresent) {
if (JACKSON_PRESENT) {
if (codec instanceof AbstractJacksonDecoder<?> abstractJacksonDecoder) {
abstractJacksonDecoder.setMaxInMemorySize(size);
}
}
if (jackson2Present) {
if (JACKSON_2_PRESENT) {
if (codec instanceof AbstractJackson2Decoder abstractJackson2Decoder) {
abstractJackson2Decoder.setMaxInMemorySize(size);
}
}
if (jaxb2Present) {
if (JAXB_2_PRESENT) {
if (codec instanceof Jaxb2XmlDecoder jaxb2XmlDecoder) {
jaxb2XmlDecoder.setMaxInMemorySize(size);
}
@@ -619,35 +619,35 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure
if (!this.registerDefaults) {
return;
}
if (kotlinSerializationCborPresent) {
if (KOTLIN_SERIALIZATION_CBOR_PRESENT) {
addCodec(this.objectReaders, new DecoderHttpMessageReader<>(this.kotlinSerializationCborDecoder != null ?
(KotlinSerializationCborDecoder) this.kotlinSerializationCborDecoder :
new KotlinSerializationCborDecoder()));
}
if (kotlinSerializationProtobufPresent) {
if (KOTLIN_SERIALIZATION_PROTOBUF_PRESENT) {
addCodec(this.objectReaders,
new DecoderHttpMessageReader<>(this.kotlinSerializationProtobufDecoder != null ?
(KotlinSerializationProtobufDecoder) this.kotlinSerializationProtobufDecoder :
new KotlinSerializationProtobufDecoder()));
}
if (jacksonPresent) {
if (JACKSON_PRESENT) {
addCodec(this.objectReaders, new DecoderHttpMessageReader<>(getJacksonJsonDecoder()));
}
else if (jackson2Present) {
else if (JACKSON_2_PRESENT) {
addCodec(this.objectReaders, new DecoderHttpMessageReader<>(getJackson2JsonDecoder()));
}
else if (kotlinSerializationJsonPresent) {
else if (KOTLIN_SERIALIZATION_JSON_PRESENT) {
addCodec(this.objectReaders, new DecoderHttpMessageReader<>(getKotlinSerializationJsonDecoder()));
}
if (jacksonSmilePresent) {
if (JACKSON_SMILE_PRESENT) {
addCodec(this.objectReaders, new DecoderHttpMessageReader<>(this.jacksonSmileDecoder != null ?
(JacksonSmileDecoder) this.jacksonSmileDecoder : new JacksonSmileDecoder()));
}
else if (jackson2SmilePresent) {
else if (JACKSON_2_SMILE_PRESENT) {
addCodec(this.objectReaders, new DecoderHttpMessageReader<>(this.jackson2SmileDecoder != null ?
(Jackson2SmileDecoder) this.jackson2SmileDecoder : new Jackson2SmileDecoder()));
}
if (jaxb2Present) {
if (JAXB_2_PRESENT) {
addCodec(this.objectReaders, new DecoderHttpMessageReader<>(this.jaxb2Decoder != null ?
(Jaxb2XmlDecoder) this.jaxb2Decoder : new Jaxb2XmlDecoder()));
}
@@ -705,12 +705,12 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure
addCodec(writers, new EncoderHttpMessageWriter<>(new ByteArrayEncoder()));
addCodec(writers, new EncoderHttpMessageWriter<>(new ByteBufferEncoder()));
addCodec(writers, new EncoderHttpMessageWriter<>(new DataBufferEncoder()));
if (nettyByteBufPresent) {
if (NETTY_BYTE_BUF_PRESENT) {
addCodec(writers, new EncoderHttpMessageWriter<>(new NettyByteBufEncoder()));
}
addCodec(writers, new ResourceHttpMessageWriter());
addCodec(writers, new EncoderHttpMessageWriter<>(CharSequenceEncoder.textPlainOnly()));
if (protobufPresent) {
if (PROTOBUF_PRESENT) {
addCodec(writers, new ProtobufHttpMessageWriter(this.protobufEncoder != null ?
(ProtobufEncoder) this.protobufEncoder : new ProtobufEncoder()));
}
@@ -765,34 +765,34 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure
@SuppressWarnings("removal")
final List<HttpMessageWriter<?>> getBaseObjectWriters() {
List<HttpMessageWriter<?>> writers = new ArrayList<>();
if (kotlinSerializationCborPresent) {
if (KOTLIN_SERIALIZATION_CBOR_PRESENT) {
addCodec(writers, new EncoderHttpMessageWriter<>(this.kotlinSerializationCborEncoder != null ?
(KotlinSerializationCborEncoder) this.kotlinSerializationCborEncoder :
new KotlinSerializationCborEncoder()));
}
if (kotlinSerializationProtobufPresent) {
if (KOTLIN_SERIALIZATION_PROTOBUF_PRESENT) {
addCodec(writers, new EncoderHttpMessageWriter<>(this.kotlinSerializationProtobufEncoder != null ?
(KotlinSerializationProtobufEncoder) this.kotlinSerializationProtobufEncoder :
new KotlinSerializationProtobufEncoder()));
}
if (jacksonPresent) {
if (JACKSON_PRESENT) {
addCodec(writers, new EncoderHttpMessageWriter<>(getJacksonJsonEncoder()));
}
else if (jackson2Present) {
else if (JACKSON_2_PRESENT) {
addCodec(writers, new EncoderHttpMessageWriter<>(getJackson2JsonEncoder()));
}
else if (kotlinSerializationJsonPresent) {
else if (KOTLIN_SERIALIZATION_JSON_PRESENT) {
addCodec(writers, new EncoderHttpMessageWriter<>(getKotlinSerializationJsonEncoder()));
}
if (jacksonSmilePresent) {
if (JACKSON_SMILE_PRESENT) {
addCodec(writers, new EncoderHttpMessageWriter<>(this.jacksonSmileEncoder != null ?
(JacksonSmileEncoder) this.jacksonSmileEncoder : new JacksonSmileEncoder()));
}
else if (jackson2SmilePresent) {
else if (JACKSON_2_SMILE_PRESENT) {
addCodec(writers, new EncoderHttpMessageWriter<>(this.jackson2SmileEncoder != null ?
(Jackson2SmileEncoder) this.jackson2SmileEncoder : new Jackson2SmileEncoder()));
}
if (jaxb2Present) {
if (JAXB_2_PRESENT) {
addCodec(writers, new EncoderHttpMessageWriter<>(this.jaxb2Encoder != null ?
(Jaxb2XmlEncoder) this.jaxb2Encoder : new Jaxb2XmlEncoder()));
}
@@ -53,9 +53,9 @@ class ClientDefaultCodecsImpl extends BaseDefaultCodecs implements ClientCodecCo
protected void extendObjectReaders(List<HttpMessageReader<?>> objectReaders) {
Decoder<?> decoder = (this.sseDecoder != null ? this.sseDecoder :
jacksonPresent ? getJacksonJsonDecoder() :
jackson2Present ? getJackson2JsonDecoder() :
kotlinSerializationJsonPresent ? getKotlinSerializationJsonDecoder() :
JACKSON_PRESENT ? getJacksonJsonDecoder() :
JACKSON_2_PRESENT ? getJackson2JsonDecoder() :
KOTLIN_SERIALIZATION_JSON_PRESENT ? getKotlinSerializationJsonDecoder() :
null);
addCodec(objectReaders, new ServerSentEventHttpMessageReader(decoder));
@@ -57,9 +57,9 @@ class ServerDefaultCodecsImpl extends BaseDefaultCodecs implements ServerCodecCo
private @Nullable Encoder<?> getSseEncoder() {
return this.sseEncoder != null ? this.sseEncoder :
jacksonPresent ? getJacksonJsonEncoder() :
jackson2Present ? getJackson2JsonEncoder() :
kotlinSerializationJsonPresent ? getKotlinSerializationJsonEncoder() :
JACKSON_PRESENT ? getJacksonJsonEncoder() :
JACKSON_2_PRESENT ? getJackson2JsonEncoder() :
KOTLIN_SERIALIZATION_JSON_PRESENT ? getKotlinSerializationJsonEncoder() :
null;
}
@@ -86,10 +86,10 @@ public class XmlEventDecoder extends AbstractDecoder<XMLEvent> {
private static final XMLInputFactory inputFactory = StaxUtils.createDefensiveInputFactory();
private static final boolean aaltoPresent = ClassUtils.isPresent(
private static final boolean AALTO_PRESENT = ClassUtils.isPresent(
"com.fasterxml.aalto.AsyncXMLStreamReader", XmlEventDecoder.class.getClassLoader());
boolean useAalto = aaltoPresent;
boolean useAalto = AALTO_PRESENT;
private int maxInMemorySize = 256 * 1024;
@@ -68,39 +68,39 @@ class DefaultHttpMessageConverters implements HttpMessageConverters {
abstract static class DefaultBuilder {
private static final boolean isJacksonPresent;
private static final boolean JACKSON_PRESENT;
private static final boolean isJackson2Present;
private static final boolean JACKSON_2_PRESENT;
private static final boolean isGsonPresent;
private static final boolean GSON_PRESENT;
private static final boolean isJsonbPresent;
private static final boolean JSONB_PRESENT;
private static final boolean isKotlinSerializationJsonPresent;
private static final boolean KOTLIN_SERIALIZATION_JSON_PRESENT;
private static final boolean isJacksonXmlPresent;
private static final boolean JACKSON_XML_PRESENT;
private static final boolean isJackson2XmlPresent;
private static final boolean JACKSON_2_XML_PRESENT;
private static final boolean isJaxb2Present;
private static final boolean JAXB_2_PRESENT;
private static final boolean isJacksonSmilePresent;
private static final boolean JACKSON_SMILE_PRESENT;
private static final boolean isJackson2SmilePresent;
private static final boolean JACKSON_2_SMILE_PRESENT;
private static final boolean isJacksonCborPresent;
private static final boolean JACKSON_CBOR_PRESENT;
private static final boolean isJackson2CborPresent;
private static final boolean JACKSON_2_CBOR_PRESENT;
private static final boolean isKotlinSerializationCborPresent;
private static final boolean KOTLIN_SERIALIZATION_CBOR_PRESENT;
private static final boolean isJacksonYamlPresent;
private static final boolean JACKSON_YAML_PRESENT;
private static final boolean isJackson2YamlPresent;
private static final boolean JACKSON_2_YAML_PRESENT;
private static final boolean isKotlinSerializationProtobufPresent;
private static final boolean KOTLIN_SERIALIZATION_PROTOBUF_PRESENT;
private static final boolean isRomePresent;
private static final boolean ROME_PRESENT;
boolean registerDefaults;
@@ -135,24 +135,24 @@ class DefaultHttpMessageConverters implements HttpMessageConverters {
static {
ClassLoader classLoader = DefaultBuilder.class.getClassLoader();
isJacksonPresent = ClassUtils.isPresent("tools.jackson.databind.ObjectMapper", classLoader);
isJackson2Present = ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader) &&
JACKSON_PRESENT = ClassUtils.isPresent("tools.jackson.databind.ObjectMapper", classLoader);
JACKSON_2_PRESENT = ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader) &&
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator", classLoader);
isGsonPresent = ClassUtils.isPresent("com.google.gson.Gson", classLoader);
isJsonbPresent = ClassUtils.isPresent("jakarta.json.bind.Jsonb", classLoader);
isKotlinSerializationJsonPresent = ClassUtils.isPresent("kotlinx.serialization.json.Json", classLoader);
isJacksonSmilePresent = isJacksonPresent && ClassUtils.isPresent("tools.jackson.dataformat.smile.SmileMapper", classLoader);
isJackson2SmilePresent = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.smile.SmileFactory", classLoader);
isJaxb2Present = ClassUtils.isPresent("jakarta.xml.bind.Binder", classLoader);
isJacksonXmlPresent = isJacksonPresent && ClassUtils.isPresent("tools.jackson.dataformat.xml.XmlMapper", classLoader);
isJackson2XmlPresent = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper", classLoader);
isJacksonCborPresent = isJacksonPresent && ClassUtils.isPresent("tools.jackson.dataformat.cbor.CBORMapper", classLoader);
isJackson2CborPresent = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.cbor.CBORFactory", classLoader);
isJacksonYamlPresent = isJacksonPresent && ClassUtils.isPresent("tools.jackson.dataformat.yaml.YAMLMapper", classLoader);
isJackson2YamlPresent = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.yaml.YAMLFactory", classLoader);
isKotlinSerializationCborPresent = ClassUtils.isPresent("kotlinx.serialization.cbor.Cbor", classLoader);
isKotlinSerializationProtobufPresent = ClassUtils.isPresent("kotlinx.serialization.protobuf.ProtoBuf", classLoader);
isRomePresent = ClassUtils.isPresent("com.rometools.rome.feed.WireFeed", classLoader);
GSON_PRESENT = ClassUtils.isPresent("com.google.gson.Gson", classLoader);
JSONB_PRESENT = ClassUtils.isPresent("jakarta.json.bind.Jsonb", classLoader);
KOTLIN_SERIALIZATION_JSON_PRESENT = ClassUtils.isPresent("kotlinx.serialization.json.Json", classLoader);
JACKSON_SMILE_PRESENT = JACKSON_PRESENT && ClassUtils.isPresent("tools.jackson.dataformat.smile.SmileMapper", classLoader);
JACKSON_2_SMILE_PRESENT = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.smile.SmileFactory", classLoader);
JAXB_2_PRESENT = ClassUtils.isPresent("jakarta.xml.bind.Binder", classLoader);
JACKSON_XML_PRESENT = JACKSON_PRESENT && ClassUtils.isPresent("tools.jackson.dataformat.xml.XmlMapper", classLoader);
JACKSON_2_XML_PRESENT = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper", classLoader);
JACKSON_CBOR_PRESENT = JACKSON_PRESENT && ClassUtils.isPresent("tools.jackson.dataformat.cbor.CBORMapper", classLoader);
JACKSON_2_CBOR_PRESENT = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.cbor.CBORFactory", classLoader);
JACKSON_YAML_PRESENT = JACKSON_PRESENT && ClassUtils.isPresent("tools.jackson.dataformat.yaml.YAMLMapper", classLoader);
JACKSON_2_YAML_PRESENT = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.yaml.YAMLFactory", classLoader);
KOTLIN_SERIALIZATION_CBOR_PRESENT = ClassUtils.isPresent("kotlinx.serialization.cbor.Cbor", classLoader);
KOTLIN_SERIALIZATION_PROTOBUF_PRESENT = ClassUtils.isPresent("kotlinx.serialization.protobuf.ProtoBuf", classLoader);
ROME_PRESENT = ClassUtils.isPresent("com.rometools.rome.feed.WireFeed", classLoader);
}
@@ -250,72 +250,72 @@ class DefaultHttpMessageConverters implements HttpMessageConverters {
this.stringMessageConverter = new StringHttpMessageConverter();
if (this.jsonMessageConverter == null) {
if (isJacksonPresent) {
if (JACKSON_PRESENT) {
this.jsonMessageConverter = new JacksonJsonHttpMessageConverter();
}
else if (isJackson2Present) {
else if (JACKSON_2_PRESENT) {
this.jsonMessageConverter = new MappingJackson2HttpMessageConverter();
}
else if (isGsonPresent) {
else if (GSON_PRESENT) {
this.jsonMessageConverter = new GsonHttpMessageConverter();
}
else if (isJsonbPresent) {
else if (JSONB_PRESENT) {
this.jsonMessageConverter = new JsonbHttpMessageConverter();
}
else if (isKotlinSerializationJsonPresent) {
else if (KOTLIN_SERIALIZATION_JSON_PRESENT) {
this.jsonMessageConverter = new KotlinSerializationJsonHttpMessageConverter();
}
}
if (this.xmlMessageConverter == null) {
if (isJacksonXmlPresent) {
if (JACKSON_XML_PRESENT) {
this.xmlMessageConverter = new JacksonXmlHttpMessageConverter();
}
else if (isJackson2XmlPresent) {
else if (JACKSON_2_XML_PRESENT) {
this.xmlMessageConverter = new MappingJackson2XmlHttpMessageConverter();
}
else if (isJaxb2Present) {
else if (JAXB_2_PRESENT) {
this.xmlMessageConverter = new Jaxb2RootElementHttpMessageConverter();
}
}
if (this.smileMessageConverter == null) {
if (isJacksonSmilePresent) {
if (JACKSON_SMILE_PRESENT) {
this.smileMessageConverter = new JacksonSmileHttpMessageConverter();
}
else if (isJackson2SmilePresent) {
else if (JACKSON_2_SMILE_PRESENT) {
this.smileMessageConverter = new MappingJackson2SmileHttpMessageConverter();
}
}
if (this.cborMessageConverter == null) {
if (isJacksonCborPresent) {
if (JACKSON_CBOR_PRESENT) {
this.cborMessageConverter = new JacksonCborHttpMessageConverter();
}
else if (isJackson2CborPresent) {
else if (JACKSON_2_CBOR_PRESENT) {
this.cborMessageConverter = new MappingJackson2CborHttpMessageConverter();
}
else if (isKotlinSerializationCborPresent) {
else if (KOTLIN_SERIALIZATION_CBOR_PRESENT) {
this.cborMessageConverter = new KotlinSerializationCborHttpMessageConverter();
}
}
if (this.yamlMessageConverter == null) {
if (isJacksonYamlPresent) {
if (JACKSON_YAML_PRESENT) {
this.yamlMessageConverter = new JacksonYamlHttpMessageConverter();
}
else if (isJackson2YamlPresent) {
else if (JACKSON_2_YAML_PRESENT) {
this.yamlMessageConverter = new MappingJackson2YamlHttpMessageConverter();
}
}
if (this.protobufMessageConverter == null) {
if (isKotlinSerializationProtobufPresent) {
if (KOTLIN_SERIALIZATION_PROTOBUF_PRESENT) {
this.protobufMessageConverter = new KotlinSerializationProtobufHttpMessageConverter();
}
}
if (isRomePresent) {
if (ROME_PRESENT) {
if (this.atomMessageConverter == null) {
this.atomMessageConverter = new AtomFeedHttpMessageConverter();
}
@@ -106,7 +106,7 @@ import org.springframework.util.xml.StaxUtils;
@SuppressWarnings("removal")
public class Jackson2ObjectMapperBuilder {
private static final boolean jackson2XmlPresent = ClassUtils.isPresent(
private static final boolean JACKSON_2_XML_PRESENT = ClassUtils.isPresent(
"com.fasterxml.jackson.dataformat.xml.XmlMapper", Jackson2ObjectMapperBuilder.class.getClassLoader());
@@ -747,7 +747,7 @@ public class Jackson2ObjectMapperBuilder {
objectMapper.setFilterProvider(this.filters);
}
if (jackson2XmlPresent) {
if (JACKSON_2_XML_PRESENT) {
objectMapper.addMixIn(ProblemDetail.class, ProblemDetailJacksonXmlMixin.class);
}
else {
@@ -97,7 +97,8 @@ public class ProtobufHttpMessageConverter extends AbstractHttpMessageConverter<M
*/
public static final String X_PROTOBUF_MESSAGE_HEADER = "X-Protobuf-Message";
private static final boolean protobufJsonFormatPresent = ClassUtils.isPresent("com.google.protobuf.util.JsonFormat", ProtobufHttpMessageConverter.class.getClassLoader());
private static final boolean PROTOBUF_JSON_FORMAT_PRESENT =
ClassUtils.isPresent("com.google.protobuf.util.JsonFormat", ProtobufHttpMessageConverter.class.getClassLoader());
private static final Map<Class<?>, Method> methodCache = new ConcurrentReferenceHashMap<>();
@@ -129,7 +130,7 @@ public class ProtobufHttpMessageConverter extends AbstractHttpMessageConverter<M
if (formatSupport != null) {
this.protobufFormatSupport = formatSupport;
}
else if (protobufJsonFormatPresent) {
else if (PROTOBUF_JSON_FORMAT_PRESENT) {
this.protobufFormatSupport = new ProtobufJavaUtilSupport(null, null);
}
else {
@@ -66,21 +66,21 @@ final class DefaultRestClientBuilder implements RestClient.Builder {
// request factories
private static final boolean httpComponentsClientPresent;
private static final boolean HTTP_COMPONENTS_CLIENT_PRESENT;
private static final boolean jettyClientPresent;
private static final boolean JETTY_CLIENT_PRESENT;
private static final boolean reactorNettyClientPresent;
private static final boolean REACTOR_NETTY_CLIENT_PRESENT;
private static final boolean jdkClientPresent;
private static final boolean JDK_CLIENT_PRESENT;
static {
ClassLoader loader = DefaultRestClientBuilder.class.getClassLoader();
httpComponentsClientPresent = ClassUtils.isPresent("org.apache.hc.client5.http.classic.HttpClient", loader);
jettyClientPresent = ClassUtils.isPresent("org.eclipse.jetty.client.HttpClient", loader);
reactorNettyClientPresent = ClassUtils.isPresent("reactor.netty.http.client.HttpClient", loader);
jdkClientPresent = ClassUtils.isPresent("java.net.http.HttpClient", loader);
HTTP_COMPONENTS_CLIENT_PRESENT = ClassUtils.isPresent("org.apache.hc.client5.http.classic.HttpClient", loader);
JETTY_CLIENT_PRESENT = ClassUtils.isPresent("org.eclipse.jetty.client.HttpClient", loader);
REACTOR_NETTY_CLIENT_PRESENT = ClassUtils.isPresent("reactor.netty.http.client.HttpClient", loader);
JDK_CLIENT_PRESENT = ClassUtils.isPresent("java.net.http.HttpClient", loader);
}
private @Nullable String baseUrl;
@@ -449,16 +449,16 @@ final class DefaultRestClientBuilder implements RestClient.Builder {
if (this.requestFactory != null) {
return this.requestFactory;
}
else if (httpComponentsClientPresent) {
else if (HTTP_COMPONENTS_CLIENT_PRESENT) {
return new HttpComponentsClientHttpRequestFactory();
}
else if (jettyClientPresent) {
else if (JETTY_CLIENT_PRESENT) {
return new JettyClientHttpRequestFactory();
}
else if (reactorNettyClientPresent) {
else if (REACTOR_NETTY_CLIENT_PRESENT) {
return new ReactorClientHttpRequestFactory();
}
else if (jdkClientPresent) {
else if (JDK_CLIENT_PRESENT) {
// java.net.http module might not be loaded, so we can't default to the JDK HttpClient
return new JdkClientHttpRequestFactory();
}
@@ -44,7 +44,7 @@ import org.springframework.util.ClassUtils;
*/
public abstract class RequestContextHolder {
private static final boolean jsfPresent =
private static final boolean JSF_PRESENT =
ClassUtils.isPresent("jakarta.faces.context.FacesContext", RequestContextHolder.class.getClassLoader());
private static final ThreadLocal<RequestAttributes> requestAttributesHolder =
@@ -123,7 +123,7 @@ public abstract class RequestContextHolder {
public static RequestAttributes currentRequestAttributes() throws IllegalStateException {
RequestAttributes attributes = getRequestAttributes();
if (attributes == null) {
if (jsfPresent) {
if (JSF_PRESENT) {
attributes = FacesRequestAttributesFactory.getFacesRequestAttributes();
}
if (attributes == null) {
@@ -57,7 +57,7 @@ public class StandardServletEnvironment extends StandardEnvironment implements C
// Defensive reference to JNDI API for JDK 9+ (optional java.naming module)
private static final boolean jndiPresent = ClassUtils.isPresent(
private static final boolean JNDI_PRESENT = ClassUtils.isPresent(
"javax.naming.InitialContext", StandardServletEnvironment.class.getClassLoader());
@@ -109,7 +109,7 @@ public class StandardServletEnvironment extends StandardEnvironment implements C
protected void customizePropertySources(MutablePropertySources propertySources) {
propertySources.addLast(new StubPropertySource(SERVLET_CONFIG_PROPERTY_SOURCE_NAME));
propertySources.addLast(new StubPropertySource(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME));
if (jndiPresent && JndiLocatorDelegate.isDefaultJndiEnvironmentAvailable()) {
if (JNDI_PRESENT && JndiLocatorDelegate.isDefaultJndiEnvironmentAvailable()) {
propertySources.addLast(new JndiPropertySource(JNDI_PROPERTY_SOURCE_NAME));
}
super.customizePropertySources(propertySources);
@@ -65,7 +65,7 @@ import org.springframework.web.context.request.WebRequest;
*/
public abstract class WebApplicationContextUtils {
private static final boolean jsfPresent =
private static final boolean JSF_PRESENT =
ClassUtils.isPresent("jakarta.faces.context.FacesContext", RequestContextHolder.class.getClassLoader());
@@ -193,7 +193,7 @@ public abstract class WebApplicationContextUtils {
beanFactory.registerResolvableDependency(ServletResponse.class, new ResponseObjectFactory());
beanFactory.registerResolvableDependency(HttpSession.class, new SessionObjectFactory());
beanFactory.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory());
if (jsfPresent) {
if (JSF_PRESENT) {
FacesDependencyRegistrar.registerFacesDependencies(beanFactory);
}
}