Revert "Allow ExchangeStrategies customizations in WebClient"
This reverts commit b3020bc484.
This commit is contained in:
@@ -41,26 +41,28 @@ The following example configures <<web-reactive.adoc#webflux-codecs, HTTP codecs
|
||||
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
|
||||
.Java
|
||||
----
|
||||
Consumer<ExchangeStrategies.Builder> customizeCodecs = builder -> {
|
||||
builder.codecs(configurer -> {
|
||||
//...
|
||||
});
|
||||
};
|
||||
ExchangeStrategies strategies = ExchangeStrategies.builder()
|
||||
.codecs(configurer -> {
|
||||
// ...
|
||||
})
|
||||
.build();
|
||||
|
||||
WebClient client = WebClient.builder()
|
||||
.exchangeStrategies(customizeCodecs)
|
||||
.exchangeStrategies(strategies)
|
||||
.build();
|
||||
----
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
val webClient = WebClient.builder()
|
||||
.exchangeStrategies { strategies ->
|
||||
strategies.codecs {
|
||||
//...
|
||||
}
|
||||
val strategies = ExchangeStrategies.builder()
|
||||
.codecs {
|
||||
// ...
|
||||
}
|
||||
.build()
|
||||
|
||||
val client = WebClient.builder()
|
||||
.exchangeStrategies(strategies)
|
||||
.build()
|
||||
----
|
||||
|
||||
Once built, a `WebClient` instance is immutable. However, you can clone it and build a
|
||||
@@ -93,44 +95,7 @@ modified copy without affecting the original instance, as the following example
|
||||
// client2 has filterA, filterB, filterC, filterD
|
||||
----
|
||||
|
||||
[[webflux-client-builder-maxinmemorysize]]
|
||||
=== MaxInMemorySize
|
||||
|
||||
Spring WebFlux configures by default a maximum size for buffering data in-memory when decoding
|
||||
HTTP responses with the `WebClient`. This avoids application memory issues if the received
|
||||
response is much larger than expected.
|
||||
|
||||
The default configured value of 256KB might not be enough for your use case, and your application
|
||||
might hit that limit with the following:
|
||||
|
||||
----
|
||||
org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer
|
||||
----
|
||||
|
||||
You can configure this limit on all default codecs with the following code sample:
|
||||
|
||||
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
|
||||
.Java
|
||||
----
|
||||
WebClient webClient = WebClient.builder()
|
||||
.exchangeStrategies(configurer ->
|
||||
configurer.codecs(codecs ->
|
||||
codecs.defaultCodecs().maxInMemorySize(2 * 1024 * 1024)
|
||||
)
|
||||
)
|
||||
.build();
|
||||
----
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
val webClient = WebClient.builder()
|
||||
.exchangeStrategies { strategies ->
|
||||
strategies.codecs {
|
||||
it.defaultCodecs().maxInMemorySize(2 * 1024 * 1024)
|
||||
}
|
||||
}
|
||||
.build()
|
||||
----
|
||||
|
||||
[[webflux-client-builder-reactor]]
|
||||
=== Reactor Netty
|
||||
|
||||
Reference in New Issue
Block a user