jetty.project icon indicating copy to clipboard operation
jetty.project copied to clipboard

ChunkAccumulator not working with empty chunks

Open scrat98 opened this issue 1 year ago • 1 comments

Jetty version(s) 12.0.8

Jetty Environment Any

Java version/vendor (use: java -version) Any

OS type/version Any

Description ChunkAccumulator uses read-only buffer in case of empty chunks that leads to the ReadOnlyBufferException https://github.com/jetty/jetty.project/blob/jetty-12.0.x/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ChunkAccumulator.java#L75

Despite that asString/asInputStream/asPublisher works fine. And even asByteBuffer (because it uses ContentSourceByteBuffer)

How to reproduce?

val server = Server(8080)
server.setHandler(object : Handler.Abstract() {
  override fun handle(request: Request, response: Response, callback: Callback): Boolean {
    Content.Source.asByteBufferAsync(request)
    callback.succeeded()
    return true
  }
})
server.start()
curl http://127.0.0.1:8080
<h2>HTTP ERROR 500 java.nio.ReadOnlyBufferException</h2>

scrat98 avatar May 06 '24 15:05 scrat98

@scrat98 please note #11598 which deprecates ChunkAccumulator. It is still draft status, but we are working on improving this area of the code. However, we will still look at a short term fix for this issue as well.

gregw avatar May 07 '24 03:05 gregw

@gregw Okay, good to know, thanks!

scrat98 avatar May 07 '24 17:05 scrat98