Setting spring.main.lazy-initialization: true
effectively disables the spring.reactor.context-propagation: AUTO
, as the ReactorAutoConfiguration
1 is never instantiated during the application startup. Turning on eager initialization alleviates this problem, which leads me to believe that this particular setup was overlooked when the AutoConfiguration
class what added. Hence, I created this issue, even though the text reads more like a question.
We are currently doing the following
@AutoConfiguration
@ConditionalOnClass(Hooks.class)
@EnableConfigurationProperties(ReactorProperties.class)
@Lazy(false)
public class EagerReactorAutoConfiguration {
EagerReactorAutoConfiguration(ReactorProperties properties) {
if (properties.getContextPropagation() == ReactorProperties.ContextPropagationMode.AUTO) {
Hooks.enableAutomaticContextPropagation();
}
}
}
This is not elegant at all and I am not super sure if there is a way of forcing eager auto configuration for such cases (or if this should be rather fixed at Spring Boot level).
Cheers!
Comment From: wilkinsona
You're right, this is a bug. Until it's fixed, you can use a filter to exclude the ReactorAutoConfiguration
bean from lazy init:
@Bean
LazyInitializationExcludeFilter eagerReactorAutoConfiguration() {
return LazyInitializationExcludeFilter.forBeanTypes(ReactorAutoConfiguration.class);
}
Comment From: Akaame
That worked out perfectly for our setup. Thanks for the quick answer @wilkinsona 🍺
Comment From: philwebb
We discussed this today and we've decided to add the LazyInitializationExcludeFilter
directly in our auto-configuration. For 4.x we'll try and change the static calls. I've opened #46014 to deal with that.