Browse Source

Update Kotlin Serialization configuration in HttpMessageConverters

As of As of spring-projects/spring-framework#35733, Spring Framework has
a dedicated method for configuring a Kotlin Serialization converter
specifically.

This commit uses this method instead of configuring the Kotlin
Serialization JSON support as a custom converter. This also removes the
`@Order` on the Kotlin converter bean itself, as there is no need to
order it in the list of custom converters anymore.

Closes gh-47917
pull/48101/head
Brian Clozel 3 months ago
parent
commit
2e52c3c35e
  1. 2
      module/spring-boot-http-converter/src/main/java/org/springframework/boot/http/converter/autoconfigure/DefaultClientHttpMessageConvertersCustomizer.java
  2. 2
      module/spring-boot-http-converter/src/main/java/org/springframework/boot/http/converter/autoconfigure/KotlinSerializationHttpMessageConvertersConfiguration.java

2
module/spring-boot-http-converter/src/main/java/org/springframework/boot/http/converter/autoconfigure/DefaultClientHttpMessageConvertersCustomizer.java

@ -52,7 +52,7 @@ class DefaultClientHttpMessageConvertersCustomizer implements ClientHttpMessageC @@ -52,7 +52,7 @@ class DefaultClientHttpMessageConvertersCustomizer implements ClientHttpMessageC
builder.withStringConverter(converter);
}
else if (converter instanceof KotlinSerializationJsonHttpMessageConverter) {
builder.addCustomConverter(converter);
builder.withKotlinSerializationJsonConverter(converter);
}
else if (converter.getSupportedMediaTypes().contains(MediaType.APPLICATION_JSON)) {
builder.withJsonConverter(converter);

2
module/spring-boot-http-converter/src/main/java/org/springframework/boot/http/converter/autoconfigure/KotlinSerializationHttpMessageConvertersConfiguration.java

@ -24,7 +24,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -24,7 +24,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.http.converter.json.KotlinSerializationJsonHttpMessageConverter;
/**
@ -40,7 +39,6 @@ class KotlinSerializationHttpMessageConvertersConfiguration { @@ -40,7 +39,6 @@ class KotlinSerializationHttpMessageConvertersConfiguration {
@Bean
@ConditionalOnMissingBean
@Order(-10) // configured ahead of JSON mappers
KotlinSerializationJsonHttpMessageConverter kotlinSerializationJsonHttpMessageConverter(Json json) {
return new KotlinSerializationJsonHttpMessageConverter(json);
}

Loading…
Cancel
Save