jetty.project
jetty.project copied to clipboard
Introduce common logic for Content.Source iterating over all chunks
Jetty version(s) 12.0.8
Enhancement Description
Currently there are number of implementations that are doing the same thing: iterate over all chunks in Content.Source and make some transformation. Below the table with all those implementations
ByteBuffer asByteBuffer(Source source) ContentSourceByteBuffer
void asByteBuffer(Source source, Promise<ByteBuffer> promise) ContentSourceByteBuffer
CompletableFuture<ByteBuffer> asByteBufferAsync(Source source) ChunkAccumulator
CompletableFuture<ByteBuffer> asByteBufferAsync(Source source, int maxSize) ChunkAccumulator
CompletableFuture<byte[]> asByteArrayAsync(Source source, int maxSize) ChunkAccumulator
CompletableFuture<RetainableByteBuffer> asRetainableByteBuffer(Source source, ByteBufferPool pool, boolean direct, int maxSize) ChunkAccumulator
String asString(Source source) ContentSourceString
String asString(Source source, Charset charset) ContentSourceString
void asString(Source source, Charset charset, Promise<String> promise) ContentSourceString
CompletableFuture<String> asStringAsync(Source source, Charset charset) ContentSourceString
InputStream asInputStream(Source source) ContentSourceInputStream
Flow.Publisher<Chunk> asPublisher(Source source) ContentSourcePublisher
void consumeAll(Source source) ContentSourceConsumer
void consumeAll(Source source, Callback callback) ContentSourceConsumer
That may lead to the inconsistent behavior and multiplies surface of mistakes (for example ChunkAccumulator has a bug while ContentSourceByteBuffer don't have such bug https://github.com/jetty/jetty.project/issues/11756)
What do you think if it good idea to implement Content.Source iterating via Flow.Publisher as a reference and all other implementations will use it and just process chunks differently? It should also cover that issue https://github.com/jetty/jetty.project/issues/11755
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
I've moved to 12.1.1 as it internal But it is a good idea and should not be dropped