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

AsyncContext completion attempt after AsyncListener.onError is called #5675 #5773

Draft
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

jbescos
Copy link
Member

@jbescos jbescos commented Oct 18, 2024

… #5675

Draft for now

@jbescos jbescos marked this pull request as draft October 18, 2024 10:37
LOGGER.log(Level.SEVERE, LocalizationMessages.ERROR_WRITING_RESPONSE_ENTITY(), ex);
if (ex.getCause() instanceof IOException) {
skipFinally = true;
LOGGER.log(Level.WARNING, "Response was sent, but there is IO issue", ex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was an issue after the response was committed.
You don't know if the response was sent or not. (it could be sitting in a buffer somewhere locally, not even sent yet)
You just know you cannot change the response anymore.

* let's just log it.
*/
LOGGER.log(Level.SEVERE, LocalizationMessages.ERROR_WRITING_RESPONSE_ENTITY(), ex);
if (ex.getCause() instanceof IOException) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ex instanceof IOException is relevant here too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if you want to check all nested causes and suppressed throwables for IOException too?

@@ -669,11 +669,18 @@ public OutputStream getOutputStream(final int contentLength) throws IOException

} catch (final Throwable ex) {
if (response.isCommitted()) {
Copy link
Member

@joakime joakime Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if (response.isCommitted()) { check is actually kinda racy.
The response could be failed in a different thread (eg: from an HTTP/2 goaway), causing the response to be flagged as committed as part of its stream close handling.
This could be false when you check, and then a microsecond later its true.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if there is IOException it does not really matter if the response was sent or not, because we cannot respond. Probably we need to skip the finally block in any case for this type of exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants