diff --git a/src/main/java/org/springframework/hateoas/config/WebClientConfigurer.java b/src/main/java/org/springframework/hateoas/config/WebClientConfigurer.java index 8e875176..e68c95a6 100644 --- a/src/main/java/org/springframework/hateoas/config/WebClientConfigurer.java +++ b/src/main/java/org/springframework/hateoas/config/WebClientConfigurer.java @@ -75,10 +75,15 @@ public class WebClientConfigurer { CustomCodecs codecs = it.customCodecs(); - encoders.forEach(codecs::encoder); - decoders.stream() // - .peek(applyDefaultConfiguration(codecs)) // - .forEach(codecs::decoder); + encoders.forEach(encoder -> codecs.register(encoder)); + decoders.forEach(decoder -> codecs.registerWithDefaultConfig(decoder, config -> { + + Integer maxInMemorySize = config.maxInMemorySize(); + + if (maxInMemorySize != null) { + decoder.setMaxInMemorySize(maxInMemorySize); + } + })); }; } @@ -103,26 +108,7 @@ public class WebClientConfigurer { public WebClient registerHypermediaTypes(WebClient webClient) { return webClient.mutate() // - .exchangeStrategies(it -> it.codecs(configurer)) // + .codecs(configurer) // .build(); } - - /** - * Returns a {@link Consumer} of {@link AbstractJackson2Decoder} that will copy the default configuration of the given - * {@link CustomCodecs} to a decoder. - * - * @param codecs must not be {@literal null}. - * @return - */ - private static Consumer applyDefaultConfiguration(CustomCodecs codecs) { - - return decoder -> codecs.withDefaultCodecConfig(config -> { - - Integer maxInMemorySize = config.maxInMemorySize(); - - if (maxInMemorySize != null) { - decoder.setMaxInMemorySize(maxInMemorySize); - } - }); - } }