Class LimitedDataBufferList

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<DataBuffer>
org.springframework.core.io.buffer.LimitedDataBufferList
All Implemented Interfaces:
Serializable, Cloneable, Iterable<DataBuffer>, Collection<DataBuffer>, List<DataBuffer>, RandomAccess

public class LimitedDataBufferList extends ArrayList<DataBuffer>
Custom List to collect data buffers with and enforce a limit on the total number of bytes buffered. For use with "collect" or other buffering operators in declarative APIs, e.g. Flux.

Adding elements increases the byte count and if the limit is exceeded, DataBufferLimitException is raised. clear() resets the count. Remove and set are not supported.

Note: This class does not automatically release the buffers it contains. It is usually preferable to use hooks such as Flux.doOnDiscard(java.lang.Class<R>, java.util.function.Consumer<? super R>) that also take care of cancel and error signals, or otherwise releaseAndClear() can be used.

Since:
5.1.11
Author:
Rossen Stoyanchev
See Also: