refactor(spring): promote @Configuration classes to @AutoConfiguration#24304
Open
heruan wants to merge 2 commits into
Open
refactor(spring): promote @Configuration classes to @AutoConfiguration#24304heruan wants to merge 2 commits into
heruan wants to merge 2 commits into
Conversation
The vaadin-spring module mixed Configuration with the AutoConfiguration.imports registration mechanism, while two of the configs were pulled in transitively via Import from SpringBootAutoConfiguration. Promote all four to AutoConfiguration so each config is registered through Spring Boot's auto-configuration mechanism and gets proxyBeanMethods=false: - SpringBootAutoConfiguration: Configuration + AutoConfigureBefore -> AutoConfiguration(before = WebMvcAutoConfiguration.class); Import of the two slices removed (they're now auto-registered independently) - VaadinScopesConfig: Configuration -> AutoConfiguration (all Beans are static, so proxyBeanMethods=false is safe) - VaadinApplicationConfiguration: Configuration -> AutoConfiguration and added to AutoConfiguration.imports - VaadinServletConfiguration: Configuration -> AutoConfiguration and added to AutoConfiguration.imports; vaadinRootMapping() now receives the forwarding Controller via injection instead of calling the bean method directly, which would have produced a duplicate Controller under proxyBeanMethods=false EnableVaadin still imports the four classes for non-Boot users - AutoConfiguration is meta-annotated with Configuration so Import keeps working; the auto-config ordering metadata is simply ignored when a class is imported manually. DevModeHandlerStopTest used to rely on the old Import chain to transitively load VaadinApplicationConfiguration (which contributes SpringApplicationContextInit); it now lists that auto-config explicitly in AutoConfigurations.of(...).
d339b3c to
4bb6ad2
Compare
…ation VaadinServletConfiguration and VaadinApplicationConfiguration used to be Import-ed by SpringBootAutoConfiguration, which carried AutoConfigureBefore(WebMvcAutoConfiguration.class). After they were promoted to independent AutoConfigurations they lost that ordering hint and could be processed after WebMvcAutoConfiguration, leaving RootExcludeHandler (the HandlerMapping that forwards / to VaadinServlet) registered too late relative to WebMvc's own mappings. The result was 404 on every Vaadin route (e.g. /, /my/login/page) in Spring Boot apps that pull WebMvcAutoConfiguration in, which broke the test-spring-security-flow ITs in flow-tests/vaadin-spring-tests/. test-spring kept passing because it uses plain Spring MVC via WebMvcConfigurationSupport rather than the auto-configuration path. Restore the original ordering by annotating both classes with AutoConfiguration(before = WebMvcAutoConfiguration.class).
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
The
vaadin-springmodule mixed@Configurationwith theAutoConfiguration.importsregistration mechanism, while two of the configs were pulled in transitively via@ImportfromSpringBootAutoConfiguration. This change promotes all four to@AutoConfigurationso each is registered through Spring Boot's auto-configuration mechanism and getsproxyBeanMethods=false.Discovery before this change
META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.importslisted onlySpringBootAutoConfiguration,SpringSecurityAutoConfiguration,VaadinScopesConfig.VaadinApplicationConfigurationandVaadinServletConfigurationwere brought in transitively via@ImportfromSpringBootAutoConfiguration.com.vaadin.flow.*exists —VaadinScanPackagesRegistraronly records user-supplied scan packages for@Routediscovery.META-INF/spring.factoriesis used only forSpringApplicationRunListener/EnvironmentPostProcessor, not auto-configuration.Changes
SpringBootAutoConfiguration:@Configuration+@AutoConfigureBefore(WebMvcAutoConfiguration.class)→@AutoConfiguration(before = WebMvcAutoConfiguration.class). Dropped@Importof the two slices (now auto-registered independently).VaadinScopesConfig:@Configuration→@AutoConfiguration(all@Beans arestatic, soproxyBeanMethods=falseis safe).VaadinApplicationConfiguration:@Configuration→@AutoConfigurationand added toAutoConfiguration.imports.VaadinServletConfiguration:@Configuration→@AutoConfigurationand added toAutoConfiguration.imports.vaadinRootMapping(...)now receives the forwardingControllervia injection instead of calling the bean method directly — this avoided creating a duplicateControllerinstance underproxyBeanMethods=false.DevModeHandlerStopTest: previously relied on the@Importchain to transitively loadVaadinApplicationConfiguration(which contributesSpringApplicationContextInit). Now opts in explicitly viaAutoConfigurations.of(...).Backward compatibility
@EnableVaadin(used by non-Boot Spring users) keeps@Import-ing the four classes.@AutoConfigurationis meta-annotated with@Configuration, so@Importcontinues to work; auto-config ordering metadata is simply ignored when imported manually.SpringSecurityAutoConfigurationwas already@AutoConfiguration— untouched.VaadinAwareSecurityContextHolderStrategyConfigurationis@Deprecated/no-op — untouched.Test plan
mvn test -pl :vaadin-spring— 436 tests pass, 0 failures, 1 pre-existing skipmvn spotless:check -pl :vaadin-spring— clean@EnableVaadinstill works for non-Boot Spring usagespringnativeAOT processors remain registered asstaticbeans ofSpringBootAutoConfiguration)🤖 Marked as draft per local convention. Please review and mark ready when satisfied.