Skip to content
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

WebMvcConfigurer is overridden by WebMvcAutoConfiguration #12389

Closed
dpash opened this issue Mar 7, 2018 · 1 comment
Closed

WebMvcConfigurer is overridden by WebMvcAutoConfiguration #12389

dpash opened this issue Mar 7, 2018 · 1 comment
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@dpash
Copy link

dpash commented Mar 7, 2018

I noticed that as a result of #11105, my custom WebMvcConfigurer.configureContentNegotiation(ContentNegotiationConfigurer configurer) changes were being overwritten by the defaults from WebMvcProperties. Regardless of the @Order value given, WebMvcAutoConfiguration.configureContentNegotiation(ContentNegotiationConfigurer configurer) always seems to happen after the user configurer.

This means the only way to configure the content negotiation is through the property files.

In 1.5, I was calling configurer.favorParameter(true), but this gets overwritten by the default property, false, in 2.0.

@bclozel mentioned in #11105 that this appears to be a general ordering problem with WebMvcConfigurer, hence raising this issue.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 7, 2018
@bclozel bclozel self-assigned this Mar 7, 2018
@bclozel bclozel added type: enhancement A general enhancement priority: normal and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 7, 2018
@bclozel bclozel added this to the 2.0.1 milestone Mar 7, 2018
@bclozel
Copy link
Member

bclozel commented Mar 7, 2018

In WebMvcAutoConfiguration, Spring Boot provides a WebMvcAutoConfigurationAdapter (unordered). If developers provide their own WebMvcConfigurer, both are unordered, so Ordered.LOWEST_PRECEDENCE.

The developer's one is processed first (contributed by the application configuration) while the auto-configuration one is processed after (contributed during the auto-configuration phase), overwriting all choices made by the first one.

We should order the auto-configuration configurer at 0, so that:

  • by default, developer's configuration will run after and enforce their opinion
  • we give enough room for developers to run things before if they want to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants