-
Notifications
You must be signed in to change notification settings - Fork 87
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
ServletOutput.println violates Async Writer contract #228
Comments
Couldn't the implementation be changed (or as a workaround, be overridden) to ... public void println(String s) throws IOException {
print(s + System.lineSeparator());
} |
@joakime that would work, although it's not that efficient.... it would be better to add the line separator as the string is converted to a byte arrray.... oh wait there is another problem with print(String) as it does the string to byte conversion character by character, with write(byte) calls inbetween. This also violates the async write contract! |
I think having less efficient but technically correct implementations is an ok compromise, as implementors can always override to whatever is most efficient for their implementations. |
Good point! I'll prepare a PR with some minimal correct implementations |
Make ServletOutputStream print methods compatible with async writing
Removed methods that were overridden to workaround jakartaee/servlet#228 in servlet-api 4.0.2, but that are now fixed in servlet-api 4.0.3. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
The ServletOutput.println methods are implemented as follows:
This violates the API contract for asynchronous writers because isReady() needs to be called before every write/print. In this case the
print(s)
may fill a buffer, which is flushed and hits TCP/IP congestion. The output stream is now not ready, but theprintln()
call is made regardless!The text was updated successfully, but these errors were encountered: