Add register methods to CodecConfigurer.CustomCodecs

The new register methods replace the now deprecated
encoder, decoder, reader, and writer methods, and also offer a choice
to opt into default properties such maxInMemorySize, if configured.

Backport of 11e321b8e7

See gh-24201
This commit is contained in:
Rossen Stoyanchev
2019-12-12 18:06:12 +00:00
parent f5b43a264a
commit 802d083df7
7 changed files with 221 additions and 67 deletions

View File

@@ -351,10 +351,10 @@ public class WebFluxConfigurationSupportTests {
@Override
protected void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
configurer.registerDefaults(false);
configurer.customCodecs().decoder(StringDecoder.textPlainOnly());
configurer.customCodecs().decoder(new Jaxb2XmlDecoder());
configurer.customCodecs().encoder(CharSequenceEncoder.textPlainOnly());
configurer.customCodecs().encoder(new Jaxb2XmlEncoder());
configurer.customCodecs().register(StringDecoder.textPlainOnly());
configurer.customCodecs().register(new Jaxb2XmlDecoder());
configurer.customCodecs().register(CharSequenceEncoder.textPlainOnly());
configurer.customCodecs().register(new Jaxb2XmlEncoder());
}
}

View File

@@ -68,8 +68,8 @@ public class ControllerMethodResolverTests {
resolvers.addCustomResolver(new CustomSyncArgumentResolver());
ServerCodecConfigurer codecs = ServerCodecConfigurer.create();
codecs.customCodecs().decoder(new ByteArrayDecoder());
codecs.customCodecs().decoder(new ByteBufferDecoder());
codecs.customCodecs().register(new ByteArrayDecoder());
codecs.customCodecs().register(new ByteBufferDecoder());
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
applicationContext.registerBean(TestControllerAdvice.class);