/** * Creates a {@link Flux} emitting {@link DataBuffer} by reading binary chunks from {@link AsyncInputStream}. * Publisher termination (completion, error, cancellation) closes the {@link AsyncInputStream}. * <p/> * The resulting {@link org.reactivestreams.Publisher} filters empty binary chunks and uses {@link DataBufferFactory} * settings to determine the chunk size. * * @param inputStream must not be {@literal null}. * @param dataBufferFactory must not be {@literal null}. * @return {@link Flux} emitting {@link DataBuffer}s. * @see DataBufferFactory#allocateBuffer() */ static Flux<DataBuffer> toPublisher(AsyncInputStream inputStream, DataBufferFactory dataBufferFactory) { return DataBufferPublisherAdapter.createBinaryStream(inputStream, dataBufferFactory) // .filter(it -> { if (it.readableByteCount() == 0) { DataBufferUtils.release(it); return false; } return true; }); }