Skip to content

With multiple ResourceHandlerRegistrationCustomizer beans in the context, only one of them is used #43490

@kzander91

Description

@kzander91

WebFluxAutoConfiguration injects ResourceHandlerRegistrationCustomizer using ObjectProvider.getIfAvailable():

this.resourceHandlerRegistrationCustomizer = resourceHandlerRegistrationCustomizer.getIfAvailable();

When multiple ResourceHandlerRegistrationCustomizer are in the context, this causes the WebFlux auto config to use an arbitrary one of them, instead of all of them.

In my case, webjars-locator-light joined my classpath due to a version update of another library. Due to this, @ConditionalOnEnabledResourceChain started matching, causing Boot to define its own customizer bean here:

@Configuration(proxyBeanMethods = false)
@ConditionalOnEnabledResourceChain
static class ResourceChainCustomizerConfiguration {
@Bean
ResourceChainResourceHandlerRegistrationCustomizer resourceHandlerRegistrationCustomizer(
WebProperties webProperties) {
return new ResourceChainResourceHandlerRegistrationCustomizer(webProperties.getResources());
}
}

This instance is the one that ends up being used, and my own is ignored.

I propose to allow an arbitrary number of customizer beans to work here, similar to the various other customizer callback interfaces used in Spring Boot's auto-configuration.


I'm currently working around this issue by marking my bean as @Primary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by anothertype: bugA general bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions