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

Default CharacterEncodingFilter not ordered correctly #2148

Closed
odrotbohm opened this issue Dec 14, 2014 · 0 comments
Closed

Default CharacterEncodingFilter not ordered correctly #2148

odrotbohm opened this issue Dec 14, 2014 · 0 comments
Labels
type: bug A general bug
Milestone

Comments

@odrotbohm
Copy link
Member

As of 1.2.0 Boot ships with a default CharacterEncodingFilter registered by HttpEncodingAutoConfiguration. The bean definition for that is annotated with @Order(Ordered.HIGHEST_PRECEDENCE) but unfortunately this declaration never gets evaluated as the component triggering the sorting only acts on the bean instance (see ServletContextInitializerBeans.addAsRegistrationBean(…) for the relevant code section).

This causes issues with the HiddenHttpMethodFilter. If this one is registered first, it already accesses the request parameters before the encoding is enforced by the CharacterEncodingFilter and the request data is already in the wrong format.

Generally speaking, I don't think @Order(…) annotations are supported on bean definitions as the BeanDefinition API doesn't allow configuring an order programatically.

I think a workaround would be to create a custom sub-class that additionally implements Ordered and returns Ordered.HIGHEST_PRECEDENCE for the calls to getOrder().

@philwebb philwebb added the type: bug A general bug label Dec 14, 2014
@philwebb philwebb added this to the 1.2.1 milestone Dec 14, 2014
odrotbohm added a commit to st-tu-dresden/salespoint that referenced this issue Dec 15, 2014
Reintroduced the bean definition for the CharacterEncodingFilter as the default registered since Boot 1.2 does not get registered first (see spring-projects/spring-boot#2148 for details.
odrotbohm added a commit to st-tu-dresden/salespoint that referenced this issue Dec 15, 2014
Reintroduced the bean definition for the CharacterEncodingFilter as the default registered since Boot 1.2 does not get registered first (see spring-projects/spring-boot#2148 for details.
odrotbohm added a commit to st-tu-dresden/salespoint that referenced this issue Jan 8, 2015
The upgrade to Spring Boot 1.2.1 allows us to finally get rid off the bean definition for CharacterEncodingFilter as the one defaulted by Boot now works as advertised.

Related tickets: #81, spring-projects/spring-boot#2148.
odrotbohm added a commit to st-tu-dresden/salespoint that referenced this issue Jan 8, 2015
The upgrade to Spring Boot 1.2.1 allows us to finally get rid off the bean definition for CharacterEncodingFilter as the one defaulted by Boot now works as advertised.

Related tickets: #81, spring-projects/spring-boot#2148.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants