Use DataBufferUtils.compose and remove writeAggregator
Use DataBufferUtils.compose instead of writeAggregator to combine multiple data buffers into one, as the write aggregator would not work when the initial data buffer did not have enough capacity to contain all subsequent buffers. Removed writeAggregator, as it is no longer needed. Issue: SPR-16365
This commit is contained in:
@@ -63,8 +63,7 @@ public abstract class AbstractDataBufferDecoder<T> extends AbstractDecoder<T> {
|
||||
public Mono<T> decodeToMono(Publisher<DataBuffer> inputStream, ResolvableType elementType,
|
||||
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
|
||||
|
||||
return Flux.from(inputStream)
|
||||
.reduce(DataBufferUtils.writeAggregator())
|
||||
return DataBufferUtils.compose(inputStream)
|
||||
.map(buffer -> decodeDataBuffer(buffer, elementType, mimeType, hints));
|
||||
}
|
||||
|
||||
|
||||
@@ -419,22 +419,6 @@ public abstract class DataBufferUtils {
|
||||
return RELEASE_CONSUMER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an aggregator function that can be used to {@linkplain Flux#reduce(BiFunction) reduce}
|
||||
* a {@code Flux} of data buffers into a single data buffer by writing all subsequent buffers
|
||||
* into the first buffer. All buffers except the first buffer are
|
||||
* {@linkplain #release(DataBuffer) released}.
|
||||
* <p>For example:
|
||||
* <pre class="code">
|
||||
* Flux<DataBuffer> flux = ...
|
||||
* Mono<DataBuffer> mono = flux.reduce(DataBufferUtils.writeAggregator());
|
||||
* </pre>
|
||||
* @see Flux#reduce(BiFunction)
|
||||
*/
|
||||
public static BinaryOperator<DataBuffer> writeAggregator() {
|
||||
return WRITE_AGGREGATOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Composes the buffers in the given {@link Publisher} into a single data buffer. Depending on
|
||||
* the {@code DataBuffer} implementation, the returned buffer may be a single buffer containing
|
||||
|
||||
Reference in New Issue
Block a user