Skip to content

Commit 568b78d

Browse files
committed
Order kotlinxJsonCodecCustomizer so user-provided customizer can go after it
Signed-off-by: Dmitry Sulman <dmitry.sulman@gmail.com>
1 parent 23bcc68 commit 568b78d

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

module/spring-boot-http-codec/src/main/java/org/springframework/boot/http/codec/autoconfigure/CodecsAutoConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ CodecCustomizer jackson2CodecCustomizer(ObjectMapper objectMapper) {
103103
static class KotlinxSerializationJsonCodecConfiguration {
104104

105105
@Bean
106+
@Order(0)
106107
@ConditionalOnBean(Json.class)
107108
CodecCustomizer kotlinxJsonCodecCustomizer(Json json, ResourceLoader resourceLoader) {
108109
ClassLoader classLoader = resourceLoader.getClassLoader();

module/spring-boot-http-codec/src/test/java/org/springframework/boot/http/codec/autoconfigure/CodecsAutoConfigurationTests.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@ void kotlinSerializationUsesUnrestrictedPredicateWhenNoOtherJsonConverterIsAvail
159159
});
160160
}
161161

162+
@Test
163+
void userProvidedCustomizerCanOverrideKotlinxJsonCodecCustomizer() {
164+
this.contextRunner.withUserConfiguration(KotlinxJsonConfiguration.class, CodecCustomizerConfiguration.class)
165+
.run((context) -> {
166+
List<CodecCustomizer> codecCustomizers = context.getBean(CodecCustomizers.class).codecCustomizers;
167+
assertThat(codecCustomizers).hasSize(3);
168+
assertThat(codecCustomizers.get(2)).isInstanceOf(TestCodecCustomizer.class);
169+
});
170+
}
171+
162172
@SuppressWarnings("unchecked")
163173
private <T> T findEncoder(AssertableApplicationContext context, Class<T> encoderClass) {
164174
ServerCodecConfigurer configurer = ServerCodecConfigurer.create();

0 commit comments

Comments
 (0)