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

Client delegation stopped working #1033

Closed
kubav182 opened this issue May 27, 2024 · 7 comments
Closed

Client delegation stopped working #1033

kubav182 opened this issue May 27, 2024 · 7 comments
Assignees

Comments

@kubav182
Copy link

In previous cloud versions 2021.x I could make Client delegation like

@Bean
Client myClient(Client client) {
 // return my client delegating default client
}

Now in version 2023.0.1 I'm getting error Client bean is in creation, so there is circular dependency.

I used it as interceptor around request/response. I understand there is RequestInterceptor and ResponseInterceptor. But RequestInterceptor just decorates RestTemplate and ResponseInterceptor does not contain for example request duration.

Is it bug or is there any other easy way how to get info about request/response + duration? I want to log this info to metric system.

@OlgaMaciaszek
Copy link
Collaborator

Hello @kubav182, thanks for creating the issue. It seems that, it's not related in any way to Spring Cloud code, but rather Spring Framework. I can double-check that for you, but in order for us to do it, please provide a minimal, complete, verifiable example that reproduces the issue.

@kubav182
Copy link
Author

@OlgaMaciaszek Hello Olga, I'm quite sure it is caused by FeignAutoConfiguration class. This class uses condition for every client, there is for example OkHttpClient:

@Bean
@ConditionalOnMissingBean(Client.class)
public Client feignClient(okhttp3.OkHttpClient client) {
    return new OkHttpClient(client);
}

As I'm creating Client there is no Client created by autoconfig (ConditionalOnMissingBean). So I'm injecting Client in method where I'm creating it so it is circle. Only solution for me was duplicate code from FeignAutoConfiguration and create client myself, but it depends on what client I'm using if okhttp, apache etc. I'm not sure if it is bug or not, but as I wrote I could do that with cloud version 2021.x.

demo-feign-client-delegation-bug.zip

@OlgaMaciaszek
Copy link
Collaborator

Hello @kubav182, we've made some breaking changes in this area in a major release, so it might have been on purpose. However, I will double-check that for you, but please provide your sample as a link to a GH repo, as the sample you've provided doesn't seem to open correctly on a Linux machine.

@kubav182
Copy link
Author

@OlgaMaciaszek Hello I pushed project to public repo https://github.com/kubav182/demo-feign-client-delegation-bug/tree/master

@OlgaMaciaszek
Copy link
Collaborator

Thanks @kubav182. Can you specify on which version that used to work? When I've downgraded this to Cloud 2021.0.9 and Boot 2.6.15 it's had the same issue.

In terms of the interceptors, those are the ones you can use, but they are from the external Feign library, so any changes would have to be reported/ added in that repo.

@spring-cloud-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-cloud-issues
Copy link

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

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

No branches or pull requests

3 participants