Skip to content

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

Closed

Description

@spring-projects-issues

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

Activity

  1. spring-projects-issues commented on Feb 18, 2016

    @spring-projects-issues
    CollaboratorAuthor

    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

  2. added
    type: bug
    in: core
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions