Repository navigation
Flush each full Netty output buffer - #1633
Merged
Merged
Conversation
ChannelOutputStream sent a full buffer with channel.write() without flushing, so Netty kept it until a flush() or until more than the write buffer high-water mark was pending. A body whose producer paused after filling one or two buffers held back what it had produced. Full buffers are now written and flushed, so only a partially filled buffer waits for an explicit flush(). Fixes #1632. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jerome Louvel <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The regression test can miss a producer timeout due to a race and does not cover a pause after the first full buffer.
2 open issues
What changed in this PR
Addresses #1632 by flushing each full Netty request or response output buffer, preventing buffered data from being held back when its producer pauses.
Changes:
- Uses
writeAndFlush()for every buffer sent and removes thesend()flag. - Adds an HTTP/1.1 and HTTP/2 regression test for a producer that pauses after writing 64 KiB.
- Documents the behavior in the class Javadoc and changelog.
| File | Description |
|---|---|
org.restlet/src/test/java/org/restlet/engine/connector/FullBufferFlushTestCase.java |
Tests delivery of full response buffers while the producer waits. |
org.restlet/src/main/java/org/restlet/engine/netty/ChannelOutputStream.java |
Flushes every sent buffer and documents the behavior. |
changes.md |
Records the Netty buffering fix for #1632. |
Review effort: Balanced
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jerome Louvel <[email protected]>
|
This was referenced Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Fixes #1632.
ChannelOutputStream, used for Netty request and response bodies, sent a full buffer withchannel.write()without flushing. Netty kept those bytes until aflush()or until more than the write buffer high-water mark (64 KiB by default) was pending. So a body whose producer paused after filling one or two 32 KiB buffers held back what it had already produced until it resumed or ended. Entities copied throughIoUtils.copy, such asInputRepresentation, only flush at the end, so any slowly produced stream was affected.Full buffers are now written and flushed, so only a partially filled buffer waits for an explicit
flush(), as with any buffered output stream.flush()andclose()already flushed, sosend()loses its flag.Testing
FullBufferFlushTestCase, over HTTP/1.1 and HTTP/2: the server writes 64 KiB and waits, without flushing, for the client to read it. It fails on the previous code (the server's wait times out) and passes with the fix.🤖 Generated with Claude Code