Skip to content

Setting spring.reactor.context-propagation has no effect when lazy initialization is enabled #45846

Open
@Akaame

Description

@Akaame

Setting spring.main.lazy-initialization: true effectively disables the spring.reactor.context-propagation: AUTO, as the ReactorAutoConfiguration1 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!

Footnotes

  1. ReactorAutoConfiguration

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions