-
Notifications
You must be signed in to change notification settings - Fork 191
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
Bean autowiring is non-deterministic when multiple beans exist with no @Priority #6301
Comments
I don't see a simple way to change this behavior except to intrdouct a
Default beans can optionally declare @jakarta.annotation.Priority. If there is no priority defined, @priority(0) is assumed. see https://quarkus.io/guides/cdi-reference#default_beans |
In theory the same problem could exist for other extensions where you can have multiple named configurations. Like Infinispan, MongoDB etc. Maybe another option would be to check if all of the returned beans have the same priority. If they do, try to resolve the default bean for the type. E.g something like:
And if that fails, just return |
Thanks @jamesnetherton and let me try this at first. |
Bug description
Relates to #5464. The code changes for that feature assume that if there are multiple beans for a given type, that they will have an
@Priority
assigned, so that the desired bean is returned from registry lookups.IMO this is only reliable for beans declared from user code. The majority of beans created by Quarkus extensions do not have any
@Priority
(AFAIK). E.g likeDataSource
beans.Thus, when Camel attempts to do autowiring, it will potentially inject a 'random' bean into components, since there is no
@Priority
enforced.The text was updated successfully, but these errors were encountered: