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

Fix a regression where response exceptions are logged unintentionally #6035

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jrhee17
Copy link
Contributor

@jrhee17 jrhee17 commented Dec 13, 2024

Motivation:

We've received reports that the following log message is printed, and also exposed when completing the response exceptionally.

Unexpected exception while closing a request:
com.linecorp.armeria.client.UnprocessedRequestException: com.linecorp.armeria.client.GoAwayReceivedException
    at com.linecorp.armeria.client.UnprocessedRequestException.of(UnprocessedRequestException.java:45)
    at com.linecorp.armeria.client.Http2ResponseDecoder.onStreamClosed(Http2ResponseDecoder.java:146)

It seems like this is a regression of the refactoring done at: https://github.com/line/armeria/pull/5800/files#diff-d82983b1c20c5f80257da8c39bb74a80d49e81efceb7a1ce63847776de9b40a9R255

I propose that if an exception completes the corresponding HttpResponse and RequestLog, then we don't log the exception in HttpResponseWrapper

Modifications:

  • boolean DefaultStreamMessage#tryClose has been added which signals whether the call closed the StreamMessage
  • the CancelledSubscriptionException check has been moved to tryClose for more consistent behavior
  • If HttpResponseWrapper#closeAction actually closed the response, then return early so that a log isn't printed
  • Added a test as a separate module to avoid flakiness due to parallel test runs

Result:

  • Unnecessary logs aren't left from HttpResponseWrapper

@jrhee17 jrhee17 added the defect label Dec 13, 2024
@jrhee17 jrhee17 added this to the 1.32.0 milestone Dec 13, 2024
@jrhee17 jrhee17 marked this pull request as ready for review December 13, 2024 05:59
Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

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

👍👍

@@ -58,6 +58,7 @@ class HttpResponseWrapper implements StreamWriter<HttpObject> {
private final EventLoop eventLoop;
private final ClientRequestContext ctx;
private final long maxContentLength;
static final String UNEXPECTED_EXCEPTION_MSG = "Unexpected exception while closing a request";
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
static final String UNEXPECTED_EXCEPTION_MSG = "Unexpected exception while closing a request";
@VisibleForTesting
static final String UNEXPECTED_EXCEPTION_MSG = "Unexpected exception while closing a request";

Copy link
Contributor

@minwoox minwoox left a comment

Choose a reason for hiding this comment

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

👍 👍 👍

Copy link
Contributor

@minwoox minwoox left a comment

Choose a reason for hiding this comment

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

👍 👍 👍

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

Successfully merging this pull request may close these issues.

3 participants