Skip to content

Conversation

rbygrave
Copy link
Contributor

@rbygrave rbygrave commented Mar 25, 2025

Given a @Factory with 2 or more bean methods that return the same type, and effectively clash on qualifier name (typically missing) then make this a compilation error.

The error suggests to add a @Named or qualifier annotation to resolve the issue.

Example:

@Factory
class MyFactory {

  @Bean
  BFace one() {
    ...
  }

  @Bean
  BFace two() {
    ...
  }

Given a @factory with 2 or more bean methods that return the same type, and effectively clash on qualifier name (typically missing) then make this a compilation error.

The error suggests to add a @nAmed or qualifier annotation to resolve the issue.

Example:
```java
@factory
class MyFactory {

  @bean
  BFace one() {
    ...
  }

  @bean
  BFace two() {
    ...
  }
```
@rbygrave
Copy link
Contributor Author

An variation to this would be to give the @Bean a default qualifier based on the method name.

So for example:

@Bean BFace one() { ...

... would get the default qualifier name of one from the method name.

Copy link
Collaborator

@SentryMan SentryMan left a comment

Choose a reason for hiding this comment

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

is this a thing that happens?

@rbygrave
Copy link
Contributor Author

is this a thing that happens?

I don't know if other people hit this, but I did hit it yesterday accidentally myself when I was looking to inject multiple Filter's via a Factory. I'm hoping people haven't hit it because it's a bit subtle and confusing when it occurs.

@SentryMan
Copy link
Collaborator

looking to inject multiple Filter's via a Factory.

I just use avaje http for filters I guess

@rbygrave rbygrave self-assigned this Mar 26, 2025
@rbygrave rbygrave added this to the 11.4 milestone Mar 26, 2025
@rbygrave rbygrave merged commit b4f4dba into master Mar 26, 2025
13 checks passed
@rbygrave rbygrave deleted the feature/detect-bean-method-clash branch March 26, 2025 08:05
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.

2 participants