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

fix: use Qualifier to force bean dependency #3098

Conversation

cromoteca
Copy link
Contributor

Fixes #3092

Copy link

codecov bot commented Dec 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.60%. Comparing base (3eb42e3) to head (e738d99).
Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3098   +/-   ##
=======================================
  Coverage   92.60%   92.60%           
=======================================
  Files          85       85           
  Lines        3164     3164           
  Branches      775      775           
=======================================
  Hits         2930     2930           
  Misses        183      183           
  Partials       51       51           
Flag Coverage Δ
unittests 92.60% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cromoteca cromoteca changed the title Use dependsOn to force bean dependency fix: use dependsOn to force bean dependency Dec 30, 2024
@@ -154,6 +155,7 @@ private static ObjectMapper createDefaultEndpointMapper(
* @return the endpoint invoker
*/
@Bean
@DependsOn("hillaEndpointObjectMapper")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures that the bean named ”hillaEndpointObjectMapper” is created before this bean, right? But what ensures that that particular mapper is used here and not some other ObjectMapper in the project?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a qualifier

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the same qualifier be used here

public SignalsConfiguration(EndpointInvoker endpointInvoker,
?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the whole DependsOn now unnecessary, as it requires the specific Hilla object mapper?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would imagine it is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find any confirmation that @Qualifier guarantees creation order. For what it worths, ChatGPT says that @DependsOn is still required. Unless we find confirmation, I'd keep it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the Hilla endpoint mapper is not created before this is called, what would be passed as the parameter?

@cromoteca cromoteca changed the title fix: use dependsOn to force bean dependency fix: use Qualifier to force bean dependency Jan 9, 2025
Artur- and others added 3 commits January 9, 2025 18:43
@taefi taefi enabled auto-merge (squash) January 9, 2025 19:58
…on-order-of-EndpointObjectMapper-and-endpointInvoker
Copy link

sonarqubecloud bot commented Jan 9, 2025

@taefi taefi merged commit c6494c1 into main Jan 9, 2025
13 checks passed
@taefi taefi deleted the fix/3092/spring-ai-module-affect-bean-creation-order-of-EndpointObjectMapper-and-endpointInvoker branch January 9, 2025 20:15
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Hilla 24.7.0.alpha6 and is also targeting the upcoming stable 24.7.0 version.

vaadin-bot pushed a commit that referenced this pull request Jan 14, 2025
* Use `dependsOn` to force bean dependency

* Add qualifier

* Add qualifier

* Remove `@DependsOn`

* Update test to match new code

---------

Co-authored-by: Artur <[email protected]>
cromoteca added a commit that referenced this pull request Jan 14, 2025
fix: use `Qualifier` to force bean dependency (#3098)

* Use `dependsOn` to force bean dependency

* Add qualifier

* Add qualifier

* Remove `@DependsOn`

* Update test to match new code

---------

Co-authored-by: Luciano Vernaschi <[email protected]>
Co-authored-by: Artur <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spring ai module affect bean creation order of hillaEndpointObjectMapper and endpointInvoker
4 participants