mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-10-07 17:59:02 +00:00
Apply auto-configured Kotlinx Serialization JSON codec customization
See gh-51842 Signed-off-by: Dmitry Sulman <dmitry.sulman@gmail.com>
This commit is contained in:
committed by
Stéphane Nicoll
parent
093ea126ca
commit
ea72da3604
+2
-1
@@ -55,7 +55,8 @@ import org.springframework.web.reactive.function.client.WebClient;
|
||||
* @since 4.0.0
|
||||
*/
|
||||
@AutoConfiguration(afterName = { "org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration",
|
||||
"org.springframework.boot.jackson2.autoconfigure.Jackson2AutoConfiguration" })
|
||||
"org.springframework.boot.jackson2.autoconfigure.Jackson2AutoConfiguration",
|
||||
"org.springframework.boot.kotlinx.serialization.json.autoconfigure.KotlinxSerializationJsonAutoConfiguration" })
|
||||
@ConditionalOnClass({ CodecConfigurer.class, WebClient.class })
|
||||
public final class CodecsAutoConfiguration {
|
||||
|
||||
|
||||
+10
@@ -27,6 +27,7 @@ import tools.jackson.databind.json.JsonMapper;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.http.codec.CodecCustomizer;
|
||||
import org.springframework.boot.kotlinx.serialization.json.autoconfigure.KotlinxSerializationJsonAutoConfiguration;
|
||||
import org.springframework.boot.test.context.FilteredClassLoader;
|
||||
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
@@ -170,6 +171,15 @@ class CodecsAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void applyKotlinxSerializationJsonAutoConfigurationBeforeCodecsAutoConfiguration() {
|
||||
this.contextRunner.withConfiguration(AutoConfigurations.of(KotlinxSerializationJsonAutoConfiguration.class))
|
||||
.run((context) -> {
|
||||
Map<String, CodecCustomizer> codecCustomizers = context.getBeansOfType(CodecCustomizer.class);
|
||||
assertThat(codecCustomizers).containsKey("kotlinxJsonCodecCustomizer");
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T findEncoder(AssertableApplicationContext context, Class<T> encoderClass) {
|
||||
ServerCodecConfigurer configurer = ServerCodecConfigurer.create();
|
||||
|
||||
Reference in New Issue
Block a user