Skip to content

Optional autowire of Map<String, BeanType> accidentally falls back to unrelated Map<String, String> [SPR-13963] #18536

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

Closed
spring-projects-issues opened this issue Feb 18, 2016 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Feb 18, 2016

Phil Webb opened SPR-13963 and commented

Upgrading Spring Boot to Framework to 4.3is not currently possible due to failure in EndpointAutoConfigurationTests.

It appears that this line in EndpointAutoConfiguration:

@Autowired(required = false)
private Map<String, HealthIndicator> healthIndicators = new HashMap<String, HealthIndicator>();

No longer works correctly as String values end up in the map.

I believe that commit 3f74a74481d is ultimately responsible as rolling this back seems to fix the issue.


Affects: 4.3 RC1

Issue Links:

Referenced from: commits 48ee9b5, 1b53edf

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

We're explicitly excluding Collection and Map beans from fallback matching now. They are being treated specifically for autowiring purposes in general, so it's not out of the ordinary to handle them specifically here as well.

However, this also means that Collection and Map beans never match unless they qualify as a full generic type match. This is easy enough to accomplish with factory methods with a specifically declared return type... but hard with a regular XML bean definition. I'm not too concerned though since this feature is not primarily about plain value holder collections; it's rather about implementations beans which happen to implement Collection / Map as well. Arbitrary Collection and Map beans can still be injected using @Resource, as before.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants