Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChunkAccumulator not working with empty chunks #11756

Closed
scrat98 opened this issue May 6, 2024 · 2 comments · Fixed by #11827
Closed

ChunkAccumulator not working with empty chunks #11756

scrat98 opened this issue May 6, 2024 · 2 comments · Fixed by #11827
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@scrat98
Copy link
Contributor

scrat98 commented May 6, 2024

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>
@gregw
Copy link
Contributor

gregw commented May 7, 2024

@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 gregw self-assigned this May 7, 2024
@scrat98
Copy link
Contributor Author

scrat98 commented May 7, 2024

@gregw Okay, good to know, thanks!

gregw added a commit that referenced this issue May 21, 2024
Fix #11756 empty byte array for no content in ChunkAccumulator
gregw added a commit that referenced this issue May 22, 2024
Fix #11756 empty byte array for no content in ChunkAccumulator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants