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

HttpOutput.write(ByteBuffer buffer) #6562

Closed
MacX19 opened this issue Jul 29, 2021 · 1 comment · Fixed by #6563
Closed

HttpOutput.write(ByteBuffer buffer) #6562

MacX19 opened this issue Jul 29, 2021 · 1 comment · Fixed by #6563
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@MacX19
Copy link

MacX19 commented Jul 29, 2021

Jetty version 9.4.43

Java version 1.8.0_261

Question
I am using the methods HttpOutput.write(ByteBuffer buffer) and HttpOutput.write(byte[] b, int off, int len) to send the response. Also I am using GzipHandler. I am testing with the same response data. When I use the write(byte[] b, int off, int len) method, the Content-Length header is set in the response. When I use the write(ByteBuffer buffer) method, the Transfer-Encoding: chunked header is set in the response. I only call the method once. I suspect the last variable is not being set correctly. Could this be just a misprint?

HttpOutput.write(int b):
https://github.com/eclipse/jetty.project/blob/735e97d5c7e41a39e759a5d76e45f0b5c1226209/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java#L1002
HttpOutput.write(byte[] b, int off, int len):
https://github.com/eclipse/jetty.project/blob/735e97d5c7e41a39e759a5d76e45f0b5c1226209/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java#L796
HttpOutput.write(ByteBuffer buffer):
https://github.com/eclipse/jetty.project/blob/735e97d5c7e41a39e759a5d76e45f0b5c1226209/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java#L926

@gregw gregw self-assigned this Jul 30, 2021
@gregw gregw added Bug For general bugs on Jetty side and removed Question labels Jul 30, 2021
@gregw
Copy link
Contributor

gregw commented Jul 30, 2021

It is indeed a buglet! Thanks for noticing and your diagnosis!
Reproduced with some extra tests and s/_written/written/ fixes those tests. But I've found a couple of other semi-related issues, so doing some more testing and improving code coverage. Standby...

@gregw gregw added this to To do in Jetty 9.4.44 FROZEN via automation Jul 30, 2021
@gregw gregw added this to To do in Jetty 10.0.7/11.0.7 FROZEN via automation Jul 30, 2021
gregw added a commit that referenced this issue Jul 30, 2021
Fixes #6562 the last written bytebuffer calculation.
Also fixed an associated issue with unnecessary flush of an empty when last calculation already signalled last.

The code coverage is not complete, so more tests are needed for this use case. Also strange that `write(ByteBuffer)` does not appear to every commence aggregation?
@gregw gregw linked a pull request Jul 30, 2021 that will close this issue
gregw added a commit that referenced this issue Jul 30, 2021
Removed the last flush of an empty buffer as was no path to that code.
gregw added a commit that referenced this issue Jul 30, 2021
Restored the last flush of an empty buffer as is needed for 0 length empty write.
gregw added a commit that referenced this issue Aug 3, 2021
Fixes #6562 the last written bytebuffer calculation.
Also fixed an associated issue with unnecessary flush of an empty when last calculation already signalled last.
gregw added a commit that referenced this issue Aug 3, 2021
Fixes #6562 the last written bytebuffer calculation.
Also fixed an associated issue with unnecessary flush of an empty when last calculation already signalled last.
@gregw gregw closed this as completed in b0140da Aug 4, 2021
Jetty 9.4.44 FROZEN automation moved this from To do to Done Aug 4, 2021
Jetty 10.0.7/11.0.7 FROZEN automation moved this from To do to Done Aug 4, 2021
gregw added a commit that referenced this issue Aug 17, 2021
Fix flaky test from #6562

Signed-off-by: Greg Wilkins <gregw@webtide.com>
gregw added a commit that referenced this issue Aug 17, 2021
Fix flaky test from #6562

Signed-off-by: Greg Wilkins <gregw@webtide.com>
gregw added a commit that referenced this issue Aug 17, 2021
Fix flaky test from #6562

Signed-off-by: Greg Wilkins <gregw@webtide.com>
gregw added a commit that referenced this issue Aug 17, 2021
Fix flaky test from #6562
Disable ipv6 test for #6624
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
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants