Skip to content

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

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

Open
wants to merge 1 commit into
base: 3.4.x
Choose a base branch
from

Conversation

nosan
Copy link
Contributor

@nosan nosan commented Jun 8, 2025

See #45846

This commits registers LazyInitializationExcludeFilter to exclude
`ReactorAutoConfiguration` from global lazy init when
'spring.reactor.context-propagation' is set to 'auto'.

Signed-off-by: Dmytro Nosan <[email protected]>
@nosan
Copy link
Contributor Author

nosan commented Jun 8, 2025

I was initially thinking of the following approach:

@AutoConfiguration
@ConditionalOnClass(Hooks.class)
@ConditionalOnProperty(name = "spring.reactor.context-propagation", havingValue = "auto")
@EnableConfigurationProperties(ReactorProperties.class)
public class ReactorAutoConfiguration {

	ReactorAutoConfiguration() {
		Hooks.enableAutomaticContextPropagation();
	}

	@Bean
	static LazyInitializationExcludeFilter reactorLazyInitializationExcludeFilter() {
		return LazyInitializationExcludeFilter.forBeanTypes(ReactorAutoConfiguration.class);
	}

}

However, ReactorProperties will stop being registered, which makes this approach somewhat risky to merge.

As a good alternative, maybe something like this:

@AutoConfiguration
@ConditionalOnClass(Hooks.class)
@EnableConfigurationProperties(ReactorProperties.class)
public class ReactorAutoConfiguration {

	@Configuration(proxyBeanMethods = false)
	@ConditionalOnProperty(name = "spring.reactor.context-propagation", havingValue = "auto")
	static class ReactorContextPropagationConfiguration {

		ReactorContextPropagationConfiguration() {
			Hooks.enableAutomaticContextPropagation();
		}

		@Bean
		static LazyInitializationExcludeFilter reactorContextPropagationLazyInitExcludeFilter() {
			return LazyInitializationExcludeFilter.forBeanTypes(ReactorContextPropagationConfiguration.class);
		}

	}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants