-
Notifications
You must be signed in to change notification settings - Fork 937
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
Do not send RST_STREAM when UnprocessedRequestException is raised #6157
Conversation
Motivation: When an `UnprocessedRequestException` is raised, the client should not send an `RST_STREAM`. Modifications: - Updated the `Http2ResponseDecoder` to avoid sending `RST_STREAM` when `UnprocessedRequestException` occurs. Result: - The client does not send an `RST_STREAM` when an `UnprocessedRequestException` is raised.
@@ -92,6 +92,9 @@ private void onWrapperCompleted(HttpResponseWrapper resWrapper, int id, @Nullabl | |||
resWrapper.onSubscriptionCancelled(cause); | |||
|
|||
if (cause != null) { | |||
if (cause instanceof UnprocessedRequestException) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may not need to send RST_STREAM when the stream was closed or a RST_STREAM was received before. I was wondering if our logic already handles the cases.
armeria/core/src/main/java/com/linecorp/armeria/client/Http2ResponseDecoder.java
Lines 138 to 150 in e08527d
if (res.isOpen()) { | |
if (!goAwayHandler.receivedGoAway()) { | |
res.close(newClosedStreamException(channel())); | |
return; | |
} | |
final int lastStreamId = conn.local().lastStreamKnownByPeer(); | |
if (stream.id() > lastStreamId) { | |
res.close(UnprocessedRequestException.of(GoAwayReceivedException.get())); | |
} else { | |
res.close(newClosedStreamException(channel())); | |
} | |
} |
armeria/core/src/main/java/com/linecorp/armeria/client/Http2ResponseDecoder.java
Line 314 in e08527d
res.close(cause); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Netty handles those cases:
https://github.com/netty/netty/blob/4.1/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ConnectionHandler.java#L808-L810
The problem that I fixed is that it tries to send RST_STREAM even though the stream was removed. Let me also add that condition to prevent the situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Netty seems to send another RST_STREAM by encoder.writeRstStream()
when the client receives an RST_STREAM or the connection is closed.
My suggestion is:
if (cause instanceof UnprocessedRequestException ||
cause instanceof ClosedStreamException) {
return;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks addressed. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Motivation:
When an
UnprocessedRequestException
is raised, the client should not send anRST_STREAM
.Modifications:
Http2ResponseDecoder
to avoid sendingRST_STREAM
whenUnprocessedRequestException
occurs.Result:
RST_STREAM
when anUnprocessedRequestException
is raised.