-
Notifications
You must be signed in to change notification settings - Fork 926
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 ExchangeType
detection for HeaderOverridingHttpRequest
.
#5787
Conversation
Motivation: The `RetryingClient` uses `ExchangeType` to decide whether to use `HttpRequestDuplicator`: https://github.com/line/armeria/blob/7474525b8cf25f02be6df7c38510a8fb6a88cb1f/core/src/main/java/com/linecorp/armeria/client/retry/RetryingClient.java#L245-L246 Thus, setting the proper `ExchangeType` is important. `ExchangeType` is currently inferred from the `HttpRequest` implementation: https://github.com/line/armeria/blob/7474525b8cf25f02be6df7c38510a8fb6a88cb1f/core/src/main/java/com/linecorp/armeria/internal/client/DefaultClientRequestContext.java#L285-L288 However, `DefaultWebClient` wraps the request, which results in incorrect `ExchangeType` detection: https://github.com/line/armeria/blob/7474525b8cf25f02be6df7c38510a8fb6a88cb1f/core/src/main/java/com/linecorp/armeria/client/DefaultWebClient.java#L113 Modifications: - Unwrapped `HeaderOverridingHttpRequest` to detect the correct `ExchangeType`. - Added `RequestOptions` when sending a request where applicable. Result: - The `ExchangeType` is now correctly detected for the default `WebClient`.
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, @minwoox !
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.
👍 👍 👍
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! 👍 👍
@@ -43,7 +50,7 @@ public OAuth2Endpoint(WebClient endpoint, String endpointPath, | |||
public CompletableFuture<T> execute(OAuth2Request oAuth2Request) { | |||
final HttpRequest request = oAuth2Request.asHttpRequest(endpointPath); | |||
final QueryParams requestParams = oAuth2Request.bodyParams(); | |||
return endpoint.execute(request) | |||
return endpoint.execute(request, UNARY_REQUEST_OPTIONS) |
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.
👍
Motivation: The `RetryingClient` uses `ExchangeType` to decide whether to use `HttpRequestDuplicator`: https://github.com/line/armeria/blob/7474525b8cf25f02be6df7c38510a8fb6a88cb1f/core/src/main/java/com/linecorp/armeria/client/retry/RetryingClient.java#L245-L246 Thus, setting the proper `ExchangeType` is important. `ExchangeType` is currently inferred from the `HttpRequest` implementation: https://github.com/line/armeria/blob/7474525b8cf25f02be6df7c38510a8fb6a88cb1f/core/src/main/java/com/linecorp/armeria/internal/client/DefaultClientRequestContext.java#L285-L288 However, `DefaultWebClient` wraps the request, which results in incorrect `ExchangeType` detection: https://github.com/line/armeria/blob/7474525b8cf25f02be6df7c38510a8fb6a88cb1f/core/src/main/java/com/linecorp/armeria/client/DefaultWebClient.java#L113 Modifications: - Unwrapped `HeaderOverridingHttpRequest` to detect the correct `ExchangeType`. - Added `RequestOptions` when sending a request where applicable. Result: - The `ExchangeType` is now correctly detected for the default `WebClient`.
Motivation:
The
RetryingClient
usesExchangeType
to decide whether to useHttpRequestDuplicator
:armeria/core/src/main/java/com/linecorp/armeria/client/retry/RetryingClient.java
Lines 245 to 246 in 7474525
ExchangeType
is important.ExchangeType
is currently inferred from theHttpRequest
implementation:armeria/core/src/main/java/com/linecorp/armeria/internal/client/DefaultClientRequestContext.java
Lines 285 to 288 in 7474525
However,
DefaultWebClient
wraps the request, which results in incorrectExchangeType
detection:armeria/core/src/main/java/com/linecorp/armeria/client/DefaultWebClient.java
Line 113 in 7474525
Modifications:
HeaderOverridingHttpRequest
to detect the correctExchangeType
.RequestOptions
when sending a request where applicable.Result:
ExchangeType
is now correctly detected for the defaultWebClient
.