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

RestClient support #3930

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jacekbilski
Copy link

Adds support for using RestClient to register an app, so far only RestTemplate or WebClient were supported.

I was trying to follow how the other two are implemented, configured and tested. My app using locally build snapshot version can register itself while having only RestClient configured.

As a bonus I fixed one typo. Also I've added logging exceptions when registration fails, it was difficult for me to figure out why registration was failing, when Spring Boot Admin was swallowing exceptions. But feel free to reject that part if you feel like it's too much.

Closes #3906.

@jacekbilski jacekbilski requested a review from a team as a code owner December 19, 2024 09:26
@jacekbilski jacekbilski changed the title Rest client support RestClient support Dec 19, 2024
@andreasfritz
Copy link
Contributor

Hi @jacekbilski
thanks for your contribution!

I have tested your code.
In my examples RestTemplateBuilder and RestClientBuilder are both present by default. So the conditions for both configurations are true. The new RestClient "wins" and gets created. This would be a breaking change for all users of the RestTemplate.
Can you please refine the conditions.

Thanks!

@jacekbilski
Copy link
Author

Hi @andreasfritz,
I've added @ConditionalOnMissingBean(RestTemplateBuilder.class) on top of RestClientRegistrationClientConfig, that should do the trick.
Unfortunately, this forces me to duplicate what's in this RestClientRegistrationClientConfig in my own application, because my app apparently does use RestTemplate to communicate with OIDC server. That means that Spring Boot will also create BlockingRegistrationClient instead of RestClientRegistrationClient, and RestTemplate is not configured to do authorized calls. But that's my problem. I have not found a way to "convince" Spring Boot to create RestClientRegistrationClient, apart from creating it by myself.
At least I don't need to maintain RestClientRegistrationClient on my side.

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

Successfully merging this pull request may close these issues.

Use RestClientBuilder, if available, to create RegistrationClient
2 participants