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

Failure analysis of a dependency injection failure suggests actions that can't be taken #31514

Open
wilkinsona opened this issue Jun 23, 2022 · 0 comments
Labels
type: bug A general bug
Milestone

Comments

@wilkinsona
Copy link
Member

wilkinsona commented Jun 23, 2022

See #31510 for background.

Consider the following failure analysis:

Parameter 1 of method sessionRepositoryFilterRegistration in org.springframework.boot.autoconfigure.session.SessionRepositoryFilterConfiguration required a single bean, but 2 were found:
	- redisCacheConnectionFactory: defined by method 'redisCacheConnectionFactory' in class path resource [com/cwg/test/config/CacheConfig.class]
	- redisSessionConnectionFactory: defined by method 'redisSessionConnectionFactory' in class path resource [com/cwg/test/config/RedisConfig.class]


Action:

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

Three actions are suggested:

  1. marking one of the beans as @Primary
  2. updating the consumer to accept multiple beans
  3. using @Qualifier to identify the bean that should be consumed

One can be taken as redisCacheConnectionFactory and redisSessionConnectionFactory are both defined by the user. Two isn't possible as the consumer is code in org.springframework.boot that a user cannot change. A variation of 3 is possible as the injection point (which the analysis identifies incorrectly) uses @SpringSessionRedisConnectionFactory. Adding @SpringSessionRedisConnectionFactory to the user's @Bean definition fixes the problem.

I wonder if we can improve the failure analysis to only suggest actions that are (likely to be) possible, or to at least refine the wording a little to explain when each is likely to be possible.

@wilkinsona wilkinsona added the type: bug A general bug label Jun 23, 2022
@wilkinsona wilkinsona added this to the 2.6.x milestone Jun 23, 2022
@wilkinsona wilkinsona changed the title Failure analysis of a dependency injection failures suggests actions that can't be taken Failure analysis of a dependency injection failure suggests actions that can't be taken Jun 23, 2022
@wilkinsona wilkinsona modified the milestones: 2.6.x, 2.7.x Nov 24, 2022
@philwebb philwebb modified the milestones: 2.7.x, 3.1.x Nov 8, 2023
@wilkinsona wilkinsona modified the milestones: 3.1.x, 3.2.x May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants