-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Create RestClient bean from a RestHighLevelClient if such a bean has been contributed by the application. #17488
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
Conversation
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public RestClient restClient(RestHighLevelClient restHighLevelClient) { |
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's already another bean method named for RestClient
with the same name. Wouldn't that create issues with bean overriding?
Maybe we could change the existing bean method and inject ObjectProvider<RestHighLevelClient>
and do everything there (return the client from the high level if it exists or create a new one from the builder). What fo you think (I've quickly looked at your PR, so I might haved missed something)?
Thank you, @bclozel
Everything is ok, at least I added a test to check this.
We could not change the existing bean method as PR has been updated. |
a bean has been contributed by the application. spring-projectsgh-17464
This significantly rework the auto-configuration to reflect the order in which things are expected. Rather than keeping a conceptual cycle between the builder and the two inner classes that are processed first, the configuration is now split in three parts: * The builder that is required and common * The configuration when the HighLevelClient is available * The RestClient configuration when that's not the case See gh-17488
Thanks again for the pr @nosan.
It is ok indeed as they are conditions to avoid creating it. However @nosan the first test in your PR has an invalid assertion. I fix it to assert that the rest client is the expected one and, of course, it failed since I've changed the assertion. The test failed as things were not created in the expected order. Unrelated to your PR but there was a conceptual cycle as the inner class (processed first) required the |
Thank you so much, @snicoll
Sorry about that 😕 |
see gh-17464