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

DefaultRestClientBuilder.defaultRequest(...) doesn't do anything #32028

Closed
ThomasKasene opened this issue Jan 14, 2024 · 4 comments
Closed

DefaultRestClientBuilder.defaultRequest(...) doesn't do anything #32028

ThomasKasene opened this issue Jan 14, 2024 · 4 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@ThomasKasene
Copy link

DefaultRestClientBuilder.defaultClient(Consumer<RestClient.RequestHeadersSpec<?>>) can be used to set a property, but that property is never actually used when building the RestClient.

Is this related to #31625?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 14, 2024
@sbrannen sbrannen added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Jan 14, 2024
@poutsma poutsma self-assigned this Jan 15, 2024
@injae-kim
Copy link
Contributor

injae-kim commented Jan 15, 2024

return new DefaultWebClient(exchange,
filterFunctions,
initUriBuilderFactory(),
defaultHeaders,
defaultCookies,
this.defaultRequest,

private ClientRequest.Builder initRequestBuilder() {
if (defaultRequest != null) {
defaultRequest.accept(this);
}

Hi @poutsma ! I found that DefaultWebClient&Builder set&pass Consumer<WebClient.RequestHeadersSpec<?>> defaultRequest; from builder to client and DefaulltWebClient use it well on initRequestBuiilder() like above!


0820210 Introduce RestClient

private Consumer<RestClient.RequestHeadersSpec<?>> defaultRequest;

public RestClient build() {
ClientHttpRequestFactory requestFactory = initRequestFactory();
UriBuilderFactory uriBuilderFactory = initUriBuilderFactory();
HttpHeaders defaultHeaders = copyDefaultHeaders();
List<HttpMessageConverter<?>> messageConverters = (this.messageConverters != null ?
this.messageConverters : initMessageConverters());
return new DefaultRestClient(requestFactory,
this.interceptors, this.initializers, uriBuilderFactory,
defaultHeaders,
this.statusHandlers,
messageConverters,
this.observationRegistry,
this.observationConvention,
new DefaultRestClientBuilder(this)
);
}

But on RestClient&Builder that introduced on above commit, I think we miss to pass defaultRequest from builder to DefaultRestClient on build() 😅
(also there's no unit test for defaultRequest on DefaultRestClient&Builder)

@injae-kim
Copy link
Contributor

injae-kim commented Jan 15, 2024

oh based on #31625, I'm not sure but maybe DefaultRestClientBuilder.defaultRequest is intended to be unused. (it's experimental feature?)

Waiting your opinion~! thanks!

Anyway, I created fix PR #32034 so feel free to close it if my fix is not what you want😃

injae-kim added a commit to injae-kim/spring-framework that referenced this issue Jan 15, 2024
@poutsma poutsma added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 17, 2024
@poutsma poutsma added this to the 6.1.4 milestone Jan 17, 2024
@poutsma
Copy link
Contributor

poutsma commented Jan 17, 2024

@ThomasKasene Indeed this was an oversight similar to #31625. In this case, however, we can enable support for the feature without making API changes, so I will commit a change shortly.

@injae-kim I did not see your PR until just now, and have already prepared a fix myself. Our fixes are fairly similar, by the looks of it, though I decided to follow the behaviour of WebClient more closely by invoking the request handler before the URI is initialised.

@injae-kim
Copy link
Contributor

already prepared a fix myself

@poutsma aha then feel free to just close my PR~! if there's anything I can contribute or help, please share to me. thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants